Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Add in new 3D mesh SDF implementation #12

Merged
merged 5 commits into from
Feb 13, 2023
Merged

Conversation

cactorium
Copy link
Contributor

PTAL for #7

I used a slightly older version of the code I was talking about before, so it looks a little different. I'm also not entirely sure how to test against a dev version of a Go package without dealing with a lot of Go module stuff, so I'll take any advice you guys have on that. It compiles at least!

It currently generates normals for vertices, faces, and edges, but effectively only uses the face normals right now. It'd involve tagging the distance measurements with their type and tracking that through all the distance comparison logic in case anyone's up for dealing with that

Copy link
Owner

@soypat soypat left a comment

Choose a reason for hiding this comment

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

Thank you so much for putting the time to write this PR! I've made a couple suggestions. The main talking point is that this file should be under the helpers/sdfexp package since I'd like to give users and myself time to test it before setting the API in stone.

sdf3-v2.go Outdated Show resolved Hide resolved
sdf3-v2.go Outdated
Bb r3.Box
}

func NewMesh(model []r3.Triangle, vertTol float64) Mesh {
Copy link
Owner

Choose a reason for hiding this comment

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

I'm wondering if this should return an error? i.e. negative vertTol, vertTol that is too large. See https://github.com/soypat/sdf/blob/main/helpers/sdfexp/import.go#L63

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

sdf3-v2.go Outdated
}
}

func minVec(a r3.Vec, b r3.Vec) r3.Vec {
Copy link
Owner

Choose a reason for hiding this comment

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

Could you use the internal/d3 functions for both minVec and maxVec and delete both these and the min max from this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

sdf3-v2.go Outdated
// pick the smaller magnitude number, effectively the distance from
// the closest triangle
func minAbs(a float64, b float64) float64 {
if math.Abs(a) < math.Abs(b) {
Copy link
Owner

Choose a reason for hiding this comment

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

Can we rewrite this as

math.Min(math.Abs(a), math.Abs(b))

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just removed that function, it was used before when the BIH traversal code was a little different, but it's now unused

sdf3-v2.go Outdated
}
}

// TODO figure out what to make public
Copy link
Owner

Choose a reason for hiding this comment

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

For now its OK to leave stuff exported since it will be living in the experimental sdfexp package. That will give us time to figure out what works as an exported field and what should be private.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me! For further reference the edge adjacency list, edge and vertex normals are all currently unused

@cactorium
Copy link
Contributor Author

PTAL, I added fixes for all the suggestions

@soypat soypat added the enhancement New feature or request label Feb 12, 2023
@soypat
Copy link
Owner

soypat commented Feb 13, 2023

Looks great to me! Tested it and works like a charm. Thanks a million @cactorium

@soypat soypat merged commit 1c91121 into soypat:main Feb 13, 2023
@cactorium cactorium deleted the sdf3-revamp branch February 13, 2023 04:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants