qbektrix / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Batch.migrate IndexedVertexList #760

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am working on creating a 3d graphics engine and using the concepts behind 
sprite.Sprite and the graphics.py demo to create a 3d set of primitive objects 
(using pyglet 1.1.4 btw).  

Now to implement picking I want to be able to change the group the primitive 
belongs to.  Based on sprite.Sprite, changing groups basically calls 
self._batch.migrate(self._vertex_list, GL_QUADS, self._group, self._batch).  
Note that self._vertexlist in sprite.Sprite is not an indexed list (see 
Sprite._create_vertex_list).  When I try to do the same thing with an indexed 
vertexlist in my 3d engine I am getting some strange behavior. Looking at 
Batch.migrate in pyglet\graphics\__init__.py it seems that the 
batch._get_domain function is always called with False as the first argument, 
indicating that it's a regular vertexlist.  Therefore IndexedVertexList are not 
supported as issue 603 mentions.  

Taking a closer look at pyglet.graphics.vertexdomain revealed that 
IndexedVertexLists do not have .migrate method overloaded to account for the 
index buffer similar to .resize.  I took the concepts in VertexList.migrate and 
IndexedVertexList.resize and came up with the solution at the link provided 
below.  Here is the link to the repository and changes I made.

https://code.google.com/r/denisg640-pyglet/source/detail?r=f3d9a9a1e5d834731350e
fed71a606a807343768

Let me know if this solves issue 603.

Original issue reported on code.google.com by denisg...@gmail.com on 28 Aug 2014 at 6:13

GoogleCodeExporter commented 9 years ago
Version 1.1.4 is considered final, the development is happening in 1.2. I can 
only suggest you to try 1.2 from repository and see if that works for you 
(although it implies some API changes).

Original comment by useboxnet on 31 Aug 2014 at 7:09

GoogleCodeExporter commented 9 years ago
I took a look and found that the development version has the same issue as 
version 1.1.4.  Note that I applied the patch to the dev to begin with. As I 
mentioned, the problem is that IndexedVertexList.migrate method is not 
overloaded to account for indices.  It is calling the superclass (VertexList) 
migrate method by default.

Denis

Original comment by denisg...@gmail.com on 2 Sep 2014 at 1:09

GoogleCodeExporter commented 9 years ago
Thanks Denis, good stuff.

Original comment by useboxnet on 2 Sep 2014 at 5:53

GoogleCodeExporter commented 9 years ago
I fixed a few bugs with the previous patch. 

1. The index numbering has to be changed if an idx_vlist is migrated if the 
vertex attributes move to a different location on the vertexbuffer and 

2. Batch.migrate should set Batch._draw_list_dirty = True.

https://code.google.com/r/denisg640-pyglet/source/detail?r=cc8ff7f03ae70464b61e6
6b7e233c8a0a43dbc42

Denis

Denis

Original comment by denisg...@gmail.com on 4 Oct 2014 at 1:00