Git Product home page Git Product logo

Comments (39)

ly29 avatar ly29 commented on June 12, 2024 2

monkey3
Seems quite useful already, now all things are controllable.

  • display list
  • don't do heavy calcs in if not faces are needed

from sverchok.

zeffii avatar zeffii commented on June 12, 2024 1

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.

ly29 avatar ly29 commented on June 12, 2024
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.

ly29 avatar ly29 commented on June 12, 2024

Needs some more settings/bigger points size etc but usable now

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

the bgl_callback must be renamed to bgl_callback_3dview then.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

That would make sense.

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

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.

zeffii avatar zeffii commented on June 12, 2024

and ^^^^^^^^^^^^^ is not that bad.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

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.

zeffii avatar zeffii commented on June 12, 2024

coolio.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Won't have time for more today, will merge for tinkering.

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

these are the peskier nodes :)

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

I copied a lot but by I spent less than on this than I did tracking down bugs for plane edges...

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

If you want tinker with point size or something bigger feel more than welcome.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

The good thing about going via bmesh is that some verification has already been done for us.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

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.

ly29 avatar ly29 commented on June 12, 2024

viewrxgl

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.

ly29 avatar ly29 commented on June 12, 2024

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.

ly29 avatar ly29 commented on June 12, 2024

What is also nice that all fixes applied to the bmesh viewer will automatically work for the rx viewer

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

error_draw
Also get crashes with Error: EXCEPTION_ACCESS_VIOLATION

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

So some extra paranoia to copy data from created bmesh since it probably deleted when falling out of scope but...

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

And it seems to be working 😃

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

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.

ly29 avatar ly29 commented on June 12, 2024

Maybe yes. But I got strange results when I tried.

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

i think we just can't bm.clear() / .free()

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

and that happens automagically at the end of the viewers scope, i think.

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

good to have the viewers again.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

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.

ly29 avatar ly29 commented on June 12, 2024

Some update stuff on this to be able to fix bugs and we could almost invite people in to try soonish.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

opstrans

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.

ly29 avatar ly29 commented on June 12, 2024

Ahh, of course I have to specify the verts because not doing that means don't want to transform any...

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

i am eager to see the speed difference :)

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

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.

ly29 avatar ly29 commented on June 12, 2024

Should make a way to run the timings 10 times or so and take minimums

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

: / can you tell what part of that 9 procent is the copy operation?

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

I could investigate but don't have more time right now

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Sometimes the ops.transform is quicker.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

So this is mostly usable, until there is time for taking it to the next level I think this does the job.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Of course the option for code path needs to be dumped

from sverchok.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.