Esempio n. 1
0
def ballBoundReflect(pos, vel, center, radius):
    ret = vel
    above = tl.distance(pos, center) - radius
    if above <= 0:
        normal = tl.normalize(pos - center)
        NoV = tl.dot(vel, normal) - 6 * tl.smoothstep(above, 0, -0.1)
        if NoV < 0:
            ret -= NoV * normal
    return ret
Esempio n. 2
0
def ballBoundReflect(pos, vel, center, radius, anti_fall=0, anti_depth=0.1):
    ret = vel
    above = tl.distance(pos, center) - radius
    if above <= 0:
        normal = tl.normalize(pos - center)
        NoV = tl.dot(vel, normal)
        if ti.static(anti_fall):
            NoV -= anti_fall * tl.smoothstep(above, 0, -anti_depth)
        if NoV < 0:
            ret -= NoV * normal
    return ret
Esempio n. 3
0
 def do_calc_sdf(self, p):
     return ts.distance(self.pos, p) - self.radius