Repository navigation
[MRG] Optimize 3D display (continued) #11577
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
Changes from 1 commit
2a75026
b168bed
a3c331d
a5c2bd5
e955f56
e227b50
ee53be5
8244c07
677e79b
d095d26
005f6fb
f74f3d7
dda0f82
1c1e4a1
7a5c50d
7c2c22e
b81c118
822f4f7
004fff2
f7795e0
da7f72c
17657a4
e43b930
7211708
5bfa368
5faaa0c
7631cfe
ad0e783
98d1161
1696d52
867819f
92daa11
a268fc7
946b9bc
ff18f5f
76d5dc7
3e230c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,8 +167,8 @@ def path_to_3d_segment(path, zs=0, zdir='z'): | |
| # Pre allocate memory | ||
| seg3d = np.ones((3, len(path))) | ||
|
|
||
| # Works either if zs is array or scalar | ||
| seg3d[2] *= zs | ||
| # Works both if zs is and array and a scalar | ||
| seg3d[2, :] *= zs | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done #6085 (comment) by @eric-wieser
When using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't look done to me - you have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absolutely, missed that -- this was also the reason for |
||
|
|
||
| pathsegs = path.iter_segments(simplify=False, curves=False) | ||
| for i, ((x, y), code) in enumerate(pathsegs): | ||
|
|
@@ -181,7 +181,6 @@ def paths_to_3d_segments(paths, zs=0, zdir='z'): | |
| """Convert paths from a collection object to 3D segments.""" | ||
|
|
||
| zs = np.broadcast_to(zs, len(paths)) | ||
|
|
||
| segs = [path_to_3d_segment(path, pathz, zdir) | ||
| for path, pathz in zip(paths, zs)] | ||
| return np.asarray(segs) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eh, this is technically an API change. At the very least, note that it returns a numpy array. |
||
|
|
@@ -194,7 +193,7 @@ def path_to_3d_segment_with_codes(path, zs=0, zdir='z'): | |
| seg3d = np.ones((3, len(path))) | ||
|
|
||
| # Works both if zs is an array and a scalar | ||
| seg3d[2] *= zs | ||
| seg3d[2, :] *= zs | ||
|
|
||
| pathsegs = path.iter_segments(simplify=False, curves=False) | ||
| codes = np.empty(len(path)) | ||
|
|
@@ -472,20 +471,21 @@ def set_3d_properties(self, zs, zdir): | |
| def do_3d_projection(self, renderer): | ||
| xs, ys, zs = self._offsets3d | ||
| vxyzis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M) | ||
| vzs = vxyzis[2] | ||
|
|
||
| fcs = (zalpha(self._facecolor3d, vxyzis[2]) if self._depthshade else | ||
| fcs = (zalpha(self._facecolor3d, vzs) if self._depthshade else | ||
| self._facecolor3d) | ||
| fcs = mcolors.to_rgba_array(fcs, self._alpha) | ||
| self.set_facecolors(fcs) | ||
|
|
||
| ecs = (zalpha(self._edgecolor3d, vxyzis[2]) if self._depthshade else | ||
| ecs = (zalpha(self._edgecolor3d, vzs) if self._depthshade else | ||
| self._edgecolor3d) | ||
| ecs = mcolors.to_rgba_array(ecs, self._alpha) | ||
| self.set_edgecolors(ecs) | ||
| PathCollection.set_offsets(self, vxyzis[0:2].T) | ||
|
|
||
| if len(vxyzis) > 0: | ||
| return min(vxyzis[2]) | ||
| if vzs.size > 0: | ||
| return min(vzs) | ||
| else: | ||
| return np.nan | ||
|
|
||
|
|
@@ -580,9 +580,9 @@ def get_vector(self, segments3d): | |
| # Store the points in a single array for easier projection | ||
| n_segments = np.sum(self._seg_sizes) | ||
| # Put all segments in a big array | ||
| self._vec = np.vstack(segments3d) | ||
| _vec = np.vstack(segments3d) | ||
| # Add a fourth dimension for quaternions | ||
| self._vec = np.hstack([self._vec, np.ones((n_segments, 1))]).T | ||
| self._vec = np.hstack([_vec, np.ones((n_segments, 1))]).T | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More efficient as which also eliminates the need for the special case when |
||
|
|
||
| def set_verts(self, verts, closed=True): | ||
| """Set 3D vertices.""" | ||
|
|
||
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.
"... is an array or a scalar"