processing / processing/processing4

OpenGL PShape stroke problem when updating vertices

Aperta
#587 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

help wanted opengl
Lingua principale
Java
Stelle
494
Fork
183
Merge medio
4h 39m
PR unite (30g)
3

Descrizione

Created by: hx2A

Description

The PShape.setVertex() method can update a PShape's geometry and will alter the filled regions but it does not alter the edges. The edges become fixed the first time it is drawn.

This works as expected for the JAVA2D renderer but does not work for P2D or P3D.

Expected Behavior

When I use PShape.setVertex() in a P2D or P3D sketch, I'd like it work the same as does for JAVA2D.

Current Behavior

For a P3D sketch, the line does not change from as it is the first time it is drawn. For a P2D sketch the line does change but is not being drawn correctly.

Steps to Reproduce

  1. Run this code:
PShape test;

void setup() {
  size(500, 500, JAVA2D);
  stroke(255, 0, 0);
  strokeWeight(15);
  fill(255);
  
  test = createShape();
  test.beginShape();
  for (int i = 0; i < 10; ++i) {
    test.vertex(0, 0);
  }
  test.endShape();
  
  frameRate(5);  
}

void draw() {
  background(128);
  for (int i = 0; i < 10; ++i) {
    test.setVertex(i, random(width), random(height));
  }
  shape(test);
}

Observe how the red line is getting updated for every frame and is always drawn in the right location.

  1. Change the renderer to P3D. You will see that the red line does not change from one frame to the next.

  2. Change the renderer to P2D. The red line does change from one frame to the next but is not being drawn correctly. It is hard to describe this in words.

Your Environment

  • Processing version: 4.0.1
  • Operating System and OS version: Linux Ubuntu

Possible Causes / Solutions

In the example above, the PShape object is created with all vertices at 0, 0. The first time draw() is called the setVertex() method is called to change the values, and those new values are being used to draw the shape. Therefore, the setVertex() method is doing its job for the first frame. For later frames, only the filled region changes.

I believe this has something to do with the tesselation process and edges or strokes in PShape? It seems it is supposed to update the tesselated geometry when setVertex() is called, and it does do this for the filled regions but not the edges. I know that Processing has an inGeo for input geometry and and separate tesselated geometry that gets sent to OpenGL for renderering. The tesselated geometry is getting refreshed for only the filled regions.

If you can spot a work-around for this that triggers the necessary geometry update, I'd greatly appreciate it. I know I can create a new shape in draw() but for my use case, which has a lot more than 10 vertices, I want to re-use one PShape object.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Parti da PShape.setVertex() e confronta i percorsi di rendering e tassellazione di P2D/P3D con JAVA2D usando lo sketch fornito. Il lavoro è completato quando i bordi del tratto si aggiornano correttamente dopo le modifiche ai vertici sia in P2D sia in P3D, senza ricreare il PShape.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
computer-graphics
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.