Created
October 11, 2017 02:33
-
-
Save EduardoLopes/17ef92bcfdd47e7def0f75ec0ab6ee26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override public function quad_add( _options:PackedQuadOptions ) : Int { | |
| def(_options.visible, true); | |
| def(_options.flipx, false); | |
| def(_options.flipy, false); | |
| var _uid = Luxe.utils.uniquehash(); | |
| //First triangle | |
| var vert0 = new Vertex( new Vector( _options.x, _options.y ), _options.color ); | |
| var vert1 = new Vertex( new Vector( _options.x+_options.w, _options.y ), _options.color ); | |
| var vert2 = new Vertex( new Vector( _options.x+_options.w, _options.y+_options.h ), _options.color ); | |
| //Second triangle | |
| var vert3 = new Vertex( new Vector( _options.x , _options.y+_options.h ), _options.color ); | |
| //var vert4 = new Vertex( new Vector( _options.x , _options.y ), _options.color ); //vertex removed | |
| //var vert5 = new Vertex( new Vector( _options.x+_options.w , _options.y+_options.h ), _options.color ); //vertex removed | |
| var vertices_count = vertices.length - 1; | |
| //tl | |
| vertices[vertices_count + 1] = vert0; | |
| //tr | |
| vertices[vertices_count + 2] = vert1; | |
| //br | |
| vertices[vertices_count + 3] = vert2; | |
| //bl | |
| vertices[vertices_count + 4] = vert3; | |
| //tl | |
| vertices[vertices_count + 5] = vert0; | |
| //br | |
| vertices[vertices_count + 6] = vert2; | |
| //create the packed quad | |
| var _quad:PackedQuad = { | |
| uid : _uid, | |
| verts : [], | |
| flipx : _options.flipx, | |
| flipy : _options.flipx, | |
| visible : _options.visible, | |
| _uv_cache : new Rectangle(0,0,1,1) | |
| } | |
| _quad.verts[0] = vert0; | |
| _quad.verts[1] = vert1; | |
| _quad.verts[2] = vert2; | |
| _quad.verts[3] = vert3; | |
| _quad.verts[4] = vert0; | |
| _quad.verts[5] = vert2; | |
| quads.set( _uid, _quad ); | |
| if(_options.uv != null) { | |
| quad_uv( _uid, _options.uv ); | |
| } | |
| //for locked geometry | |
| dirty = true; | |
| return _uid; | |
| } //add_quad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment