Exemple #1
0
    def foo():
        for u in model.verts:
            u.s1 = u.id
        for e in model.edges:
            e.s2 = e.id
        for c in model.cells:
            c.s3 = c.id

        ti.mesh_local(model.verts.s1, model.edges.s2, model.cells.s3)
        for u in model.verts:
            a, b, c = 0, 0, 0
            for i in range(u.verts.size):
                a += u.verts[i].s1
            for i in range(u.edges.size):
                b += u.edges[i].s2
            for i in range(u.cells.size):
                c += u.cells[i].s3
            u.s = a * b * c

        for u in model.verts:
            for i in range(u.verts.size):
                u.a += u.verts[i].s1
        for u in model.verts:
            for i in range(u.edges.size):
                u.b += u.edges[i].s2
        for u in model.verts:
            for i in range(u.cells.size):
                u.c += u.cells[i].s3
        for u in model.verts:
            u.s_ = u.a * u.b * u.c
Exemple #2
0
 def foo(cache: ti.template()):
     if ti.static(cache):
         ti.mesh_local(ext_a, model.verts.a)
     for f in model.faces:
         m = f.verts[0].id + f.verts[1].id + f.verts[2].id
         f.verts[0].a += m
         f.verts[1].a += m
         f.verts[2].a += m
         ext_a[f.verts[0].id] += m
         ext_a[f.verts[1].id] += m
         ext_a[f.verts[2].id] += m
Exemple #3
0
 def foo(cache: ti.template()):
     for v in model.verts:
         v.s = v.id
     if ti.static(cache):
         ti.mesh_local(ext_a, model.verts.a)
     for f in model.faces:
         m = f.verts[0].s + f.verts[1].s + f.verts[2].s
         f.verts[0].a += m
         f.verts[1].a += m
         f.verts[2].a += m
         for i in range(3):
             ext_a[f.verts[i].id] += m