-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Unity] Textured Point Cloud #1293
Conversation
- TextureCoordinate to Point class - MapTexture to PointCloud class - Enqueue to FrameQueue class
private float Remap(float value, float from1, float to1, float from2, float to2) | ||
{ | ||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2; | ||
vertices = vertices ?? new Points.Vertex[points.Count]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use this for Unity. Vertex
matches Vector3
, TextureCoordinate
matches Vector2
.
Use a Vector3[]
instead of Vertex[]
and manually marshal the array.
Then PointCloudGenerator.cs#L126 wouldn't allocate so much.
You're also allocating here: PointCloudGenerator.cs#L132, that's what Vector3.Zero
is for...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds right, how much do you think this affects performance though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One less copy per vertex should help.
Still, there's more to do, particles aren't really the most performant way of rendering point clouds... Meshes are better suited, since you can update all of Mesh.vertices
at once with one write (assuming you already have the pointcloud as a Vector3[]
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ev-mp , I've removed the redundant allocation PointCloudGenerator.cs#L132 in the next commit, but the vertex copy still requires change.
This PR adds a few addition to the C# wrapper, and provides a demo of creating texturized point cloud in Unity.
C# Additions:
PointCloud.MapTexture
andPoints.TextureCoordinate
to allow users to map a color image to the point cloud's points.FrameQueue.Enqueue
allowing users to push frames to a frame queue.FrameQueue.PollForFrames
.Unity Additions:
PointCloudGenerator.cs
to allow texture mapping of color framesKnown Issue
High memory usage / memory leak when displaying textured point cloud in Unity.