
    \
j}                         d Z ddlZddlZddlT ddlmZmZmZ  ej        dej	                  Z
eeeedZd Zd Zd	 Zd
 Z G d d          Z G d d          Z G d de          Z G d de          ZdS )aF  Manage related vertex attributes within a single vertex domain.

A vertex "domain" consists of a set of attribute descriptions that together
describe the layout of one or more vertex buffers which are used together to
specify the vertices in a primitive.  Additionally, the domain manages the
buffers used to store the data and will resize them as necessary to accommodate
new vertices.

Domains can optionally be indexed, in which case they also manage a buffer
containing vertex indices.  This buffer is grown separately and has no size
relation to the attribute buffers.

Applications can create vertices (and optionally, indices) within a domain
with the :py:meth:`VertexDomain.create` method.  This returns a
:py:class:`VertexList` representing the list of vertices created.  The vertex
attribute data within the group can be modified, and the changes will be made
to the underlying buffers automatically.

The entire domain can be efficiently drawn in one step with the
:py:meth:`VertexDomain.draw` method, assuming all the vertices comprise
primitives of the same OpenGL primitive mode.
    N)*)
allocationvertexattributevertexbufferzJ
    (?P<attribute>[^/]*)
    (/ (?P<usage> static|dynamic|stream|none))?
)staticdynamicstreamnonec                 f    | dz  } | | dz	  z  } | | dz	  z  } | | dz	  z  } | | dz	  z  } | | dz	  z  } | dz   S )N                )vs    V/DATA/AppData/hermes/venv/lib/python3.11/site-packages/pyglet/graphics/vertexdomain.py_nearest_pow2r   N   sW     FAaKAaKAaKAaKAbLAq5L    c                     t                               |           }|                    d          }t          j        |          }|                    d          }|r|dk     }t
          |         }n	t          }d}|||fS )a  Create an attribute and usage pair from a format string.  The
    format string is as documented in `pyglet.graphics.vertexattribute`, with
    the addition of an optional usage component::

        usage ::= attribute ( '/' ('static' | 'dynamic' | 'stream' | 'none') )?

    If the usage is not given it defaults to 'dynamic'.  The usage corresponds
    to the OpenGL VBO usage hint, and for ``static`` also indicates a
    preference for interleaved arrays.  If ``none`` is specified a buffer
    object is not created, and vertex data is stored in system memory.

    Some examples:

    ``v3f/stream``
        3D vertex position using floats, for stream usage
    ``c4b/static``
        4-byte color attribute, for static usage

    :return: attribute, usage
    	attributeusager
   T)_usage_format_rematchgroupr   create_attribute
_gl_usagesGL_DYNAMIC_DRAW)fmtr   attribute_formatr   r   vbos         r   create_attribute_usager"   Z   s    * ""3''E{{;//01ABBIKK  E 6/!5!eS  r   c                  8    d | D             }t          |          S )a  Create a vertex domain covering the given attribute usage formats.
    See documentation for :py:func:`create_attribute_usage` and
    :py:func:`pyglet.graphics.vertexattribute.create_attribute` for the grammar
    of these format strings.

    :rtype: :py:class:`VertexDomain`
    c                 ,    g | ]}t          |          S r   r"   .0fs     r   
<listcomp>z!create_domain.<locals>.<listcomp>   !    SSSa.q11SSSr   )VertexDomainattribute_usage_formatsattribute_usagess     r   create_domainr/   }   s)     TS;RSSS()))r   c                  8    d | D             }t          |          S )a%  Create an indexed vertex domain covering the given attribute usage
    formats.  See documentation for :py:class:`create_attribute_usage` and
    :py:func:`pyglet.graphics.vertexattribute.create_attribute` for the grammar
    of these format strings.

    :rtype: :py:class:`VertexDomain`
    c                 ,    g | ]}t          |          S r   r%   r&   s     r   r)   z)create_indexed_domain.<locals>.<listcomp>   r*   r   )IndexedVertexDomainr,   s     r   create_indexed_domainr3      s)     TS;RSSS/000r   c                   L    e Zd ZdZdZdZd Zd Zd Zd Z	d Z
dd
Zd Zd Zd	S )r+   zManagement of a set of vertex lists.

    Construction of a vertex domain is usually done with the
    :py:func:`create_domain` function.
    r   r   c                    t          j        | j                  | _        d}|D ]$\  }}}t	          |t
          j                  rd} n%g }g }g | _        |D ]\  }}}|r.t	          |t
          j                  r|	                                 |t          k    r+|                    |           |                    |           l|                    |           t          j        |j        | j        j        z  ||          |_        |j        |j        _        |f|j        _        | j                            |j        |ff           |rt          j        |           |d         j        }	t          j        |	| j        j        z  t                    }
|	|
_        | j                            |
|f           |                    |           |D ]	}|
|_        
|| _        i | _        |D ]}t	          |t
          j                  rG|j        }d| j        vr
i | j        d<   || j        d         vsJ d|z              || j        d         |<   ct	          |t
          j                  rX|j        }d| j        vr
g | j        d<   || j        d         vsJ d	|z              | j        d                             ||           |j        }|| j        vsJ d
|z              || j        |<   d S )NFT)r   r!   r   )r   genericz-More than one generic attribute with index %dmulti_tex_coordsz6More than one multi_tex_coord attribute for texture %dz"More than one "%s" attribute given)r   	Allocator_initial_count	allocator
isinstancer   MultiTexCoordAttributebuffer_attributesTexCoordAttribute$convert_to_multi_tex_coord_attributeGL_STATIC_DRAWappendr   create_mappable_bufferstridecapacitybufferelement_size
attributesinterleave_attributesextendattribute_namesGenericAttributeindextextureinsertplural)selfr.   have_multi_texcoordr   _static_attributesrG   r   r!   rC   rE   rL   rM   names                 r   __init__zVertexDomain.__init__   sz   #-d.ABB $/ 	 	OIq!)_%KLL &*# 
!#%5 	P 	P!Iuc" Az)_=^'_'_ A>>@@@&&!((333!!),,,, !!),,,#/#F$t~'>>S$* $* $*	  1:0@	 -/8l	 +&--y/?).NOOOO  
	*12CDDD&q)0F!800H H HF"(F"))63D*EFFF/000. * *	#)	   %!# 	7 	7I)_%EFF 7! D$88868D(3D$8$CCCCCeK DCC9B$Y/66I'MNN 7#+%T-AAA?AD();<d&:;M&NNNNLwV ONN$%78??SSSS '4?2224X[_4_222-6$T**+	7 	7r   c                 @    | j         D ]}	 |`# t          $ r Y w xY wd S N)rG   rE   AttributeError)rP   r   s     r   __del__zVertexDomain.__del__   sM      	 	I$$!   	 	s   
c                 t   	 | j                             |          S # t          j        $ r}t	          |j                  }| xj        dz  c_        | j        D ]"\  }}|                    ||j	        z             #| j         
                    |           | j                             |          cY d}~S d}~ww xY w)z5Allocate vertices, resizing the buffers if necessary.r   N)r:   allocr   AllocatorMemoryExceptionr   requested_capacity_versionr=   resizerF   set_capacity)rP   counterD   rE   rR   s         r   _safe_alloczVertexDomain._safe_alloc   s    	/>''...2 	/ 	/ 	/$Q%9::HMMQMM!3 > >	h)<<====N''111>''........	/s    B7BB2,B72B7c                 |   	 | j                             |||          S # t          j        $ r}t	          |j                  }| xj        dz  c_        | j        D ]"\  }}|                    ||j	        z             #| j         
                    |           | j                             |||          cY d}~S d}~ww xY w)z7Reallocate vertices, resizing the buffers if necessary.r   N)r:   reallocr   r\   r   r]   r^   r=   r_   rF   r`   )rP   startra   	new_countrb   rD   rE   rR   s           r   _safe_realloczVertexDomain._safe_realloc   s    	C>))%	BBB2 	C 	C 	C$Q%9::HMMQMM!3 > >	h)<<====N''111>))%	BBBBBBBB	Cs    B;BB60B;6B;c                 N    |                      |          }t          | ||          S )zCreate a :py:class:`VertexList` in this domain.

        :Parameters:
            `count` : int
                Number of vertices to create.

        :rtype: :py:class:`VertexList`
        )rc   
VertexList)rP   ra   rf   s      r   createzVertexDomain.create  s)       ''$u---r   Nc                 4   t          t                     | j        D ]Q\  }}|                                 |D ]5}|                                 |                    |j        j                   6Rt          j	        rt                       |t          ||j        |j                   n| j                                        \  }}t!          |          }|dk    rn|dk    rt          ||d         |d                    nmt"                              dd          r+t'          |z  | }t)          |z  | }t+          ||||           n't-          ||          D ]\  }	}
t          ||	|
           | j        D ]\  }}|                                 t1                       dS )a9  Draw vertices in the domain.

        If `vertex_list` is not specified, all vertices in the domain are
        drawn.  This is the most efficient way to render primitives.

        If `vertex_list` specifies a :py:class:`VertexList`, only primitives in
        that list will be drawn.

        :Parameters:
            `mode` : int
                OpenGL drawing mode, e.g. ``GL_POINTS``, ``GL_LINES``, etc.
            `vertex_list` : `~pyglet.graphics.vertexdomain.VertexList`
                Vertex list to draw, or ``None`` for all lists in this domain.

        Nr   r   r   )glPushClientAttribGL_CLIENT_VERTEX_ARRAY_BITr=   bindenableset_pointerrE   ptrr   _workaround_vbo_finishglFinishglDrawArraysrf   ra   r:   get_allocated_regionslengl_infohave_versionGLintGLsizeiglMultiDrawArrayszipunbindglPopClientAttribrP   modevertex_listrE   rG   r   startssizes	primcountrf   sizerR   s               r   drawzVertexDomain.draw  s     	5666"&"8 	< 	<FJKKMMM' < <	  """%%i&6&:;;;;< . 	JJJ"{0+2CDDDD N@@BBMFEFIA~~aT6!9eAh7777%%a++ 4)+f5 9,u5!$yAAAA#&vu#5#5 4 4KE4 ud3333/ 	 	IFAMMOOOOr   c                     | j         j         S rW   )r:   r   rP   s    r   	_is_emptyzVertexDomain._is_emptyA  s    >(((r   c                 J    d| j         j        t          |           | j        fz  S )Nz
<%s@%x %s>)	__class____name__idr:   r   s    r   __repr__zVertexDomain.__repr__D  s!    t~64$.QQQr   rW   )r   
__module____qualname____doc__r^   r9   rU   rY   rc   rh   rk   r   r   r   r   r   r   r+   r+      s         
 HNE7 E7 E7N  
/ 
/ 
/
C 
C 
C
. 
. 
.- - - -^) ) )R R R R Rr   r+   c                   *   e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZd Zd Zd Zd Zd Zd Zd	 Zd
 Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Z e j        d             Z ed             Z!e!j        d             Z!ed             Z"e"j        d             Z"ed             Z#e#j        d             Z#dS )rj   zzA list of vertices within a :py:class:`VertexDomain`.  Use
    :py:meth:`VertexDomain.create` to construct this list.
    Nc                 0    || _         || _        || _        d S rW   )domainrf   ra   )rP   r   rf   ra   s       r   rU   zVertexList.__init__[  s    



r   c                     | j         S )zEGet the number of vertices in the list.

        :rtype: int
        )ra   r   s    r   get_sizezVertexList.get_sizea  s    
 zr   c                     | j         S )z^Get the domain this vertex list belongs to.

        :rtype: :py:class:`VertexDomain`
        )r   r   s    r   
get_domainzVertexList.get_domainh  s    
 {r   c                 <    | j                             ||            dS )zDraw this vertex list in the given OpenGL mode.

        :Parameters:
            `mode` : int
                OpenGL drawing mode, e.g. ``GL_POINTS``, ``GL_LINES``, etc.

        Nr   r   rP   r   s     r   r   zVertexList.drawo  s"     	t$$$$$r   c                    | j                             | j        | j        |          }|| j        k    r| j         j        D ]v}|                    |j        | j        | j                  }|                    |j        || j                  }|j        dd         |j        dd<   |                                 w|| _        || _        d| _	        d| _
        d| _        d| _        d| _        d| _        d| _        dS )zResize this group.

        :Parameters:
            `count` : int
                New number of vertices in the list.

        N)r   rh   rf   ra   rG   
get_regionrE   array
invalidate_colors_cache_version_fog_coords_cache_version_edge_flags_cache_version_normals_cache_version_secondary_colors_cache_version_tex_coords_cache_version_vertices_cache_version)rP   ra   	new_startr   oldnews         r   r_   zVertexList.resizey  s    K--dj$*eLL	
""![3 ! !	**9+;+/:tzC C**9+;+4djB B"y|	!!!    

%)")-&)-&&*#/3,)-&'+$$$r   c                 Z    | j         j                            | j        | j                   dS zDelete this group.N)r   r:   deallocrf   ra   r   s    r   deletezVertexList.delete  s'    %%dj$*=====r   c                    t          |j                                                  t          | j        j                                                  k    s
J d            |                    | j                  }| j        j                                        D ]\  }}|                    |j        | j	        | j                  }|j        |         }|                    |j        || j                  }|j
        dd         |j
        dd<   |                                 | j        j                            | j	        | j                   || _        || _	        d| _        d| _        d| _        d| _        d| _        d| _        d| _        dS )a3  Move this group from its current domain and add to the specified
        one.  Attributes on domains must match.  (In practice, used to change
        parent state of some vertices).

        :Parameters:
            `domain` : `VertexDomain`
                Domain to migrate this vertex list to.

        zDomain attributes must match.N)listrJ   keysr   rc   ra   itemsr   rE   rf   r   r   r:   r   r   r   r   r   r   r   r   )rP   r   r   keyold_attributer   new_attributer   s           r   migratezVertexList.migrate  su    F*//1122,1133445 5 56U5 5 5 &&tz22	"&+"="C"C"E"E 	 	C**=+?TZXXC"237M**=+?DJWWC9QQQ<CIaaaLNN%%dj$*===
%)")-&)-&&*#/3,)-&'+$$$r   c                     | j         j        |         }|                    |j        | j        | j                  }||j        d d <   |                                 d S rW   )r   rG   r   rE   rf   ra   r   r   )rP   idatar   regions        r   _set_attribute_datazVertexList._set_attribute_data  sV    K*1-	%%i&6
DJOOQQQr   c                    | j         | j        j        k    rK| j        }|j        d         }|                    |j        | j        | j                  | _        |j        | _         | j        }|	                                 |j
        S )zArray of color data.colors)r   r   r^   rJ   r   rE   rf   ra   _colors_cacher   r   rP   r   r   r   s       r   r   zVertexList.colors  sz     %)===[F.x8I!*!5!5i6F
TXT^!_!_D)/D&#|r   c                     || j         d d <   d S rW   )r   rP   r   s     r   r   zVertexList.colors  s    AAAr   c                    | j         | j        j        k    rK| j        }|j        d         }|                    |j        | j        | j                  | _        |j        | _         | j        }|	                                 |j
        S )zArray of fog coordinate data.
fog_coords)r   r   r^   rJ   r   rE   rf   ra   _fog_coords_cacher   r   r   s       r   r   zVertexList.fog_coords  }     )T[-AAA[F.|<I%.%9%9 $*dj&: &:D"-3_D*'|r   c                     || j         d d <   d S rW   )r   r   s     r   r   zVertexList.fog_coords      !r   c                    | j         | j        j        k    rK| j        }|j        d         }|                    |j        | j        | j                  | _        |j        | _         | j        }|	                                 |j
        S )zArray of edge flag data.
edge_flags)r   r   r^   rJ   r   rE   rf   ra   _edge_flags_cacher   r   r   s       r   r   zVertexList.edge_flags  r   r   c                     || j         d d <   d S rW   )r   r   s     r   r   zVertexList.edge_flags  r   r   c                    | j         | j        j        k    rK| j        }|j        d         }|                    |j        | j        | j                  | _        |j        | _         | j        }|	                                 |j
        S )zArray of normal vector data.normals)r   r   r^   rJ   r   rE   rf   ra   _normals_cacher   r   r   s       r   r   zVertexList.normals  s}     &$+*>>>[F.y9I"+"6"6 $*dj#: #:D*0/D'$|r   c                     || j         d d <   d S rW   )r   r   s     r   r   zVertexList.normals      QQQr   c                    | j         | j        j        k    rK| j        }|j        d         }|                    |j        | j        | j                  | _        |j        | _         | j        }|	                                 |j
        S )zArray of secondary color data.secondary_colors)r   r   r^   rJ   r   rE   rf   ra   _secondary_colors_cacher   r   r   s       r   r   zVertexList.secondary_colors	  s~     /4;3GGG[F./ABI+4+?+? $*dj,: ,:D(39?D0-|r   c                     || j         d d <   d S rW   )r   r   s     r   r   zVertexList.secondary_colors  s    #'aaa   r   c                 &   d| j         j        vr| j        | j         j        k    rK| j         }|j        d         }|                    |j        | j        | j                  | _        |j        | _        | j        }|	                                 |j
        S dS )z!Array of texture coordinate data.r7   
tex_coordsN)r   rJ   r   r^   r   rE   rf   ra   _tex_coords_cacher   r   r   s       r   r   zVertexList.tex_coords  s     T[%@@@-1EEE"2<@	)2)=)=$dj$**> *>&17.+F<4r   c                 0    | j         r|| j         d d <   d S d S rW   )r   r   s     r   r   zVertexList.tex_coords,  s,    ? 	&!%DOAAA	& 	&r   c                    d| j         j        vr| j        | j         j        k    rj| j         }|j        d         }g | _        |D ]@}| j                            |                    |j        | j        | j	                             A|j        | _        | j        }g }|D ]0}|
                                 |                    |j                   1|S dS )z$Multi-array texture coordinate data.r   r7   N)r   rJ   r   r^   r   rA   r   rE   rf   ra   r   r   )rP   r   r   ar   r   s         r   r7   zVertexList.multi_tex_coords1  s     t{:::-1EEE"23EF	)+&" ; ;A*11!,,$*dj3: 3: ; ; ; ;17.+FE & &QW%%%%L4r   c                     | j         rat          dt          | j                  d          D ]?}|t          |          k    r d S ||         r||         | j        |         j        d d <   >d S d S )Nr   r   )r7   rangerw   r   r   )rP   r   r   s      r   r7   zVertexList.multi_tex_coordsG  s      	A1c$"8991== A As4yy==EE!W A9=aD*1-3AAA6	A 	AA Ar   c                    | j         | j        j        k    rK| j        }|j        d         }|                    |j        | j        | j                  | _        |j        | _         | j        }|	                                 |j
        S )z Array of vertex coordinate data.vertices)r   r   r^   rJ   r   rE   rf   ra   _vertices_cacher   r   r   s       r   r   zVertexList.verticesP  s}     '4;+???[F.z:I#,#7#7 $*dj$: $:D +1?D(%|r   c                     || j         d d <   d S rW   )r   r   s     r   r   zVertexList.vertices^  s    aaar   )$r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rU   r   r   r   r_   r   r   r   propertyr   setterr   r   r   r   r   r7   r   r   r   r   rj   rj   H  s         M  $ $N!"&*# $O"      % % %, , ,:> > >, , ,B   
 
 X
 ]  ]   X " " "   X " " "   X ^  ^   X ( ( (   X  & & &   X* A A A   X _    _     r   rj   c                   J     e Zd ZdZdZef fd	Zd Zd Zd Z	d Z
d
d	Z xZS )r2   zManagement of a set of indexed vertex lists.

    Construction of an indexed vertex domain is usually done with the
    `create_indexed_domain` function.
    r   c                 p   t          t          |                               |           t          j        | j                  | _        || _        t          j	        |         | _
        t          j        | j
                  | _        t          j        | j        j        | j        z  t"                    | _        d S )N)target)superr2   rU   r   r8   _initial_index_countindex_allocatorindex_gl_typer   _c_typesindex_c_typectypessizeofindex_element_sizer   rB   rD   GL_ELEMENT_ARRAY_BUFFERindex_buffer)rP   r.   r   r   s      r   rU   zIndexedVertexDomain.__init__k  s    !4((112BCCC)3D4MNN*+4]C"(-0A"B"B(? )D,CC*, , ,r   c                 d   	 | j                             |          S # t          j        $ r}t	          |j                  }| xj        dz  c_        | j                            || j	        z             | j         
                    |           | j                             |          cY d}~S d}~ww xY w)z4Allocate indices, resizing the buffers if necessary.r   N)r   r[   r   r\   r   r]   r^   r   r_   r   r`   )rP   ra   rb   rD   s       r   _safe_index_allocz%IndexedVertexDomain._safe_index_allocw  s    	5'--e4442 	5 	5 	5$Q%9::HMMQMM$$X0G%GHHH --h777'--e44444444	5s    B/A9B*$B/*B/c                 l   	 | j                             |||          S # t          j        $ r}t	          |j                  }| xj        dz  c_        | j                            || j	        z             | j         
                    |           | j                             |||          cY d}~S d}~ww xY w)z6Reallocate indices, resizing the buffers if necessary.r   N)r   re   r   r\   r   r]   r^   r   r_   r   r`   )rP   rf   ra   rg   rb   rD   s         r   _safe_index_reallocz'IndexedVertexDomain._safe_index_realloc  s    	I'//uiHHH2 	I 	I 	I$Q%9::HMMQMM$$X0G%GHHH --h777'//uiHHHHHHHH	Is    B3A;B.(B3.B3c                 |    |                      |          }|                     |          }t          | ||||          S )zCreate an :py:class:`IndexedVertexList` in this domain.

        :Parameters:
            `count` : int
                Number of vertices to create
            `index_count`
                Number of indices to create

        )rc   r   IndexedVertexList)rP   ra   index_countrf   index_starts        r   rk   zIndexedVertexDomain.create  s@       '',,[99 ue[+NNNr   c                     | j         |z  }| j         |z  }t          j        | j        |z            }| j                            |||          S )zGet a region of the index buffer.

        :Parameters:
            `start` : int
                Start of the region to map.
            `count` : int
                Number of indices to map.

        :rtype: Array of int
        )r   r   POINTERr   r   r   )rP   rf   ra   
byte_start
byte_countptr_types         r   get_index_regionz$IndexedVertexDomain.get_index_region  sP     ,u4
,u4
>$"3e";<< ++J
HMMMr   Nc           	          t          t                      j        D ]Q\  }}|                                 |D ]5}|                                 |                    |j        j                   6R j                                         t          j
        rt                       |8t          ||j         j         j        j        |j         j        z  z              n* j                                        \  }}t'          |          }|dk    rn|dk    r9t          ||d          j         j        j        |d          j        z  z              nt(                              dd          r\ fd|D             } t-          j        t0                    |z  t3          |z  |  }t5          |z  | }t7          || j        ||           nBt9          ||          D ]1\  }	}
t          ||
 j         j        j        |	 j        z  z              2 j                                          j        D ]\  }}|                                 t=                       dS )a"  Draw vertices in the domain.

        If `vertex_list` is not specified, all vertices in the domain are
        drawn.  This is the most efficient way to render primitives.

        If `vertex_list` specifies a :py:class:`VertexList`, only primitives in
        that list will be drawn.

        :Parameters:
            `mode` : int
                OpenGL drawing mode, e.g. ``GL_POINTS``, ``GL_LINES``, etc.
            `vertex_list` : `IndexedVertexList`
                Vertex list to draw, or ``None`` for all lists in this domain.

        Nr   r   r   c                 >    g | ]}|j         z  j        j        z   S r   )r   r   rr   )r'   srP   s     r   r)   z,IndexedVertexDomain.draw.<locals>.<listcomp>  s-    ^^^RS!d558I8MM^^^r   )rm   rn   r=   ro   rp   rq   rE   rr   r   r   rs   rt   glDrawElementsr   r   r   r   r   rv   rw   rx   ry   r   r   GLvoidGLintptrr{   glMultiDrawElementsr}   r~   r   r   s   `           r   r   zIndexedVertexDomain.draw  s     	5666"&"8 	< 	<FJKKMMM' < <	  """%%i&6&:;;;;< 	   . 	JJJ"4!8$:L,0;3J243 34 4 4 4 !0FFHHMFEFIA~~atU1Xt/A#04vay4CZ7ZZ\ \ \ \%%a++ \^^^^W]^^^<&.009<9@TW]?^_ 9,u5#D%1CVYWWWW#&vu#5#5 \ \KE4"4t/A#'#4#854CZ;Z#Z\ \ \ \ 	  """/ 	 	IFAMMOOOOr   rW   )r   r   r   r   r   GL_UNSIGNED_INTrU   r   r   rk   r   r   __classcell__r   s   @r   r2   r2   c  s         
 7F 
, 
, 
, 
, 
, 
,	5 	5 	5	I 	I 	IO O ON N N 4 4 4 4 4 4 4 4r   r2   c                        e Zd ZdZdZdZ fdZd Z fdZ fdZ	 fdZ
d Zed	             Zej        d
             Z xZS )r   zA list of vertices within an :py:class:`IndexedVertexDomain` that are
    indexed. Use :py:meth:`IndexedVertexDomain.create` to construct this list.
    Nc                 x    t          t          |                               |||           || _        || _        d S rW   )r   r   rU   r   r   )rP   r   rf   ra   r   r   r   s         r   rU   zIndexedVertexList.__init__  s<    &&//uEEE&&r   c                 <    | j                             ||            d S rW   r   r   s     r   r   zIndexedVertexList.draw  s     t$$$$$r   c                 F   | j         }t          t          |                               |           || j         k    r'| j         |z
  fd| j        D             | j        dd<   | j                            | j        | j        |          }|| j        k    rw| j        	                    | j        | j                  }| j        	                    | j        | j                  }|j
        dd         |j
        dd<   |                                 || _        || _        d| _        dS )zResize this group.

        :Parameters:
            `count` : int
                New number of vertices in the list.
            `index_count` : int
                New number of indices in the list.

        c                     g | ]}|z   S r   r   r'   r   diffs     r   r)   z,IndexedVertexList.resize.<locals>.<listcomp>  s    >>>Aq4x>>>r   N)rf   r   r   r_   indicesr   r   r   r   r   r   r   _indices_cache_version)	rP   ra   r   	old_startr   r   r   r  r   s	          @r   r_   zIndexedVertexList.resize  s+    J	&&--e444 
"":	)D>>>>>>>DLO K33d.= =	(((+.. $"24 4C+.. $"24 4C9QQQ<CIaaaLNN$&&*###r   c                     t          t          |                                            | j        j                            | j        | j                   dS r   )r   r   r   r   r   r   r   r   )rP   r   s    r   r   zIndexedVertexList.delete  sG    &&--///#++D,<d>NOOOOOr   c                   	 | j         }| j        }t          t          |                               |           || j         k    rX| j         |z
  	|                    | j        | j                  }|j        }	fd|D             |dd<   |	                                 |                    | j        | j                  }|j
                            | j        | j                   | j                            | j                  }| j                            || j                  }|j        dd         |j        dd<   |	                                 || _        d| _        dS )aL  Move this group from its current indexed domain and add to the 
        specified one.  Attributes on domains must match.  (In practice, used 
        to change parent state of some vertices).

        :Parameters:
            `domain` : `IndexedVertexDomain`
                Indexed domain to migrate this vertex list to.

        c                     g | ]}|z   S r   r   r  s     r   r)   z-IndexedVertexList.migrate.<locals>.<listcomp>+  s    <<<1a$h<<<r   N)rf   r   r   r   r   r   r   r   r   r   r   r   r   r  )rP   r   r  
old_domainr   old_indicesr   r   r   r  r   s            @r   r   zIndexedVertexList.migrate  sR    J	[
&&..v666 
"":	)D001A4CSTTF ,K<<<<<<<KN ))$*:D<LMM 	"**4+;T=MNNNK11$2BCC	k**9d6FGGy|	!!!$&*###r   c                     | j                             | j        | j                  }||j        d d <   |                                 d S rW   )r   r   r   r   r   r   )rP   r   r   s      r   _set_index_dataz!IndexedVertexList._set_index_data;  sK    --d.0 0QQQr   c                     | j         | j        j        k    r8| j        }|                    | j        | j                  | _        |j        | _         | j        }|                                 |j        S )zArray of index data.)	r  r   r^   r   r   r   _indices_cacher   r   )rP   r   r   s      r   r  zIndexedVertexList.indicesB  sm     &$+*>>>[F"("9"9 $"2#4 #4D*0/D'$|r   c                     || j         d d <   d S rW   )r  r   s     r   r  zIndexedVertexList.indicesO  r   r   )r   r   r   r   r  r  rU   r   r_   r   r   r  r   r  r   r  r  s   @r   r   r     s          N!' ' ' ' '% % %+ + + + +@P P P P P
"+ "+ "+ "+ "+H   
 
 X
 ^  ^    r   r   )r   rer   	pyglet.glpyglet.graphicsr   r   r   compileVERBOSEr   r@   r   GL_STREAM_DRAWGL_STREAM_DRAW_ARBr   r   r"   r/   r3   r+   rj   r2   r   r   r   r   <module>r$     s  H . 
			      E E E E E E E E E E2:  Z   	 
	 	 	 !  !  !F	* 	* 	*	1 	1 	1pR pR pR pR pR pR pR pRfX  X  X  X  X  X  X  X v| | | | |, | | |~o o o o o
 o o o o or   