Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding strokeMode() to access SIMPLE lines. #7390

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

perminder-17
Copy link
Contributor

@perminder-17 perminder-17 commented Nov 23, 2024

fixes : #7278

Created a method strokeMode() to access SIMPLE lines for faster fps.

@perminder-17 perminder-17 changed the title webgl-lines Adding strokeMode() to access SIMPLE lines. Nov 24, 2024
@perminder-17
Copy link
Contributor Author

The test which are currently failing are

  1. visualTest('StrokeShader', (p5, screenshot) => {
  2. visualTest('With the default monospace font', function (p5, screenshot) {

I have observed that these tests are also failing in the current Dev 2.0 branch. Therefore, I believe that this pull request is not related to the issues affecting these tests.

@perminder-17 perminder-17 marked this pull request as ready for review November 24, 2024 14:25
@davepagurek
Copy link
Contributor

It looks like they're hitting an error in the simple lines code, we might need to double check that it's accessing the properties correctly:
image

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @perminder-17, this is looking good, great explanation of the use of both modes!

* @property {String} FULLY
* @final
*/
export const FULLY = 'fully';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor note, could we call this FULL instead of FULLY to use the same adjective form as SIMPLE?

*/

fn.strokeMode = function(mode){
if(mode === constants.SIMPLE){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this return the current mode if we call it with no arguments?

@@ -1398,7 +1399,7 @@ class Geometry {
if (dirOK) {
this._addSegment(begin, end, fromColor, toColor, dir);
}

if(!this.renderer._simpleLines){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since p5.Geometry created manually won't have a renderer passed in, I think we need to handle the case where there is no renderer, and mayube default to the full line behaviour:

Suggested change
if(!this.renderer._simpleLines){
if(!this.renderer?._simpleLines){

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do you think we could intent the block inside this to keep the indentation consistent everywhere?

@@ -1520,6 +1522,7 @@ class Geometry {
}
}
this.lineVertices.push(...a, ...b, ...a, ...b, ...b, ...a);
if(!this.renderer._simpleLines){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here, we might need to check for the existence of the renderer first:

Suggested change
if(!this.renderer._simpleLines){
if(!this.renderer?._simpleLines){

@@ -67,6 +68,8 @@ vec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) {

void main() {
HOOK_beforeVertex();

if(!uSimpleLines){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we indent the block below?

* let lineLength = 50;
*
* beginShape(LINES);
* vertex(centerX - lineLength / 2, centerY, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you feel about having a 3D shape like a default sphere(), and maybe a single Bezier curve in each of these examples? I feel like those are two cases where the difference is clear: the sphere probably looks the same regardless, and the curve (especially with a higher stroke weight) will look very disjoint without full curve decorations.

We can also make the examples more than 100x100 if that makes it easier to see since I think the new site's layout accommodates that decently.

@perminder-17
Copy link
Contributor Author

Adjusting the indentation caused unexpected spacing issues in the code, making it difficult to review. I apologize for any inconvenience this may have caused. Also, the checks were failing because we need to check the existence of the renderer first. Thanks for the suggestions:)

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, looks great!

@davepagurek davepagurek merged commit e986778 into processing:dev-2.0 Nov 26, 2024
2 checks passed
@perminder-17 perminder-17 deleted the webgl-line branch November 27, 2024 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants