Comments (39)
Seems quite useful already, now all things are controllable.
- display list
- don't do heavy calcs in if not faces are needed
from sverchok.
i think we can get away with this..
def stop(self):
bgl_callback.callback_disable(self.n_id, overlay='POST_PIXEL')
if self.activate:
bgl_callback.callback_enable(self.n_id, self.current_draw_data, overlay='POST_PIXEL')
from sverchok.
def draw_bmesh(context, args):
obj_list = args[0]
face_list = args[1]
col_list = args[2]
edg_list = args[3]
edge_col, vert_col = args[4]
for verts, vert_index, colors, edges in zip(obj_list, face_list, col_list, edg_list):
if vert_index:
bgl.glBegin(bgl.GL_TRIANGLES)
for idx in range(0, len(vert_index), 3):
p0 = verts[vert_index[idx]]
p1 = verts[vert_index[idx + 1]]
p2 = verts[vert_index[idx + 2]]
bgl.glColor3f(*colors[idx//3])
bgl.glVertex3f(*p0)
bgl.glVertex3f(*p1)
bgl.glVertex3f(*p2)
bgl.glEnd()
if vert_col:
bgl.glBegin(bgl.GL_POINTS)
bgl.glColor3f(*vert_col)
for vert in verts:
bgl.glVertex3f(*vert)
bgl.glEnd()
if edge_col:
bgl.glBegin(bgl.GL_LINES)
bgl.glColor3f(*edge_col)
for x, y in edges:
bgl.glVertex3f(*verts[x])
bgl.glVertex3f(*verts[y])
bgl.glEnd()
from sverchok.
Needs some more settings/bigger points size etc but usable now
from sverchok.
the bgl_callback must be renamed to bgl_callback_3dview
then.
from sverchok.
That would make sense.
from sverchok.
oh.. after looking carefully, the callback disable doesn't even care what kind overlay it is ..
def stop(self):
bgl_callback.callback_disable(self.n_id)
if self.activate:
bgl_callback.callback_enable(self.n_id, self.current_draw_data, overlay='POST_PIXEL')
from sverchok.
and ^^^^^^^^^^^^^
is not that bad.
from sverchok.
Yeah I noticed, made a bgl_callback_3dview
with the overlay, when we merge we can switch over index viewer and removed the _2d file
from sverchok.
coolio.
from sverchok.
Won't have time for more today, will merge for tinkering.
from sverchok.
these are the peskier nodes :)
from sverchok.
I copied a lot but by I spent less than on this than I did tracking down bugs for plane edges...
from sverchok.
If you want tinker with point size or something bigger feel more than welcome.
from sverchok.
The good thing about going via bmesh is that some verification has already been done for us.
from sverchok.
I think I will make a quick hack and allow drawing of vertices, edges and faces via conversion to bm.
Later we can make a more direct data path.
from sverchok.
Below complete new code for viewer node for rx data. I think this is asign that some abstractions are working out nicely.
@stateful
class ViewNode(BMViewNode):
bl_idname = "SvRxNodeRxViewGL"
label = "Viewer Rx GL"
def __call__(self,
verts: Vertices = Required,
edges: Edges = None,
faces: Faces = None,
mat: Matrix = None):
bm = bmesh_from_pydata(verts[:,:3].tolist(), edges, faces)
super().__call__(bm, mat)
from sverchok.
These viewers should be considered a minimal level and could do with more advanced options, for example gatering colors from the bmesh, showing different materials per loop etc.
from sverchok.
What is also nice that all fixes applied to the bmesh viewer will automatically work for the rx viewer
from sverchok.
Also get crashes with Error: EXCEPTION_ACCESS_VIOLATION
from sverchok.
So some extra paranoia to copy data from created bmesh since it probably deleted when falling out of scope but...
from sverchok.
And it seems to be working 😃
from sverchok.
how expensive is a deepcopy of a bm, because the transforms are pretty rapid using bmesh.ops.transform( matrix )
.
I wouldn't be surprised if
bmnew = bmesh.ops.copy(bm)`
bmesh.ops.transform(bmnew, matrix)
is faster than iterating over a list of verts and transforming them.
from sverchok.
Maybe yes. But I got strange results when I tried.
from sverchok.
i think we just can't bm.clear() / .free()
from sverchok.
and that happens automagically at the end of the viewers scope, i think.
from sverchok.
good to have the viewers again.
from sverchok.
I made sure the data is copied now, for the bm case it was okay because the incoming bm is kept in the data tree cache
from sverchok.
Some update stuff on this to be able to fix bugs and we could almost invite people in to try soonish.
from sverchok.
So this is what happens when I try with bmesh.ops.transform
So updated to working below
if mat is not None:
if self.node.use_ops_trans:
bm = bm.copy()
matrix = mu.Matrix(mat)
bmesh.ops.transform(bm, matrix=matrix, verts=bm.verts)
# was this not working
# bmesh.ops.transform(bm, matrix=matrix)
verts = [v.co[:] for v in bm.verts]
bm.normal_update()
normals = [f.normal[:] for f in bm.faces]
else:
matrix = mu.Matrix(mat)
verts = [matrix * v.co for v in bm.verts]
bm.normal_update()
mat33 = matrix.to_3x3()
normals = [(mat33 * f.normal)[:] for f in bm.faces]
from sverchok.
Ahh, of course I have to specify the verts because not doing that means don't want to transform any...
from sverchok.
i am eager to see the speed difference :)
from sverchok.
No totally coherent but leaning this way it seems.
Icosphere subdiv=5 and 3 matrices
SvRxNodeBMViewGL: GL View - ops.trans 0.079932 49.5%
SvRxNodeBMViewGL: GL View mat*v 0.064907 40.2%
from sverchok.
Should make a way to run the timings 10 times or so and take minimums
from sverchok.
: / can you tell what part of that 9 procent is the copy operation?
from sverchok.
I could investigate but don't have more time right now
from sverchok.
Sometimes the ops.transform is quicker.
from sverchok.
So this is mostly usable, until there is time for taking it to the next level I think this does the job.
from sverchok.
Of course the option for code path needs to be dumped
from sverchok.
Related Issues (20)
- Documentation HOT 8
- Int and Float socket can be limited HOT 2
- Mesh - rxdata_from_pydata HOT 28
- BMesh nodes HOT 10
- Dynamic Socket Issues HOT 3
- API to simplify mesh creation HOT 3
- The great namning debacle HOT 18
- Node wishlist HOT 48
- stethoscope v2 HOT 44
- startup error message HOT 1
- Timings HOT 74
- .foreach mesh out HOT 15
- torus np scriptnode HOT 39
- Rx Bridges (remakes of real bridges) HOT 1
- Texture script node HOT 52
- Index Viewer HOT 70
- Linspace and arrange HOT 16
- Some refactoring going on HOT 5
- vectorization concept HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sverchok.