processing / processing/processing4

OpenGL PShape stroke problem when updating vertices

Abierto
#587 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

help wanted opengl
Lenguaje dominante
Java
Estrellas
494
Forks
183
Merge medio
4 h 39 min
PR fusionados (30 d)
3

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza por PShape.setVertex() y compara las rutas de renderizado y teselación de P2D/P3D con JAVA2D usando el sketch proporcionado. Se considera terminado cuando los bordes del trazo se actualizan correctamente después de cambiar los vértices tanto en P2D como en P3D sin volver a crear el PShape.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
computer-graphics
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.