faça um prompt para uma ai que gera addon para o blender 3d para simulação de cloths customizavel caindo sobre algum objeto para simular fisica avançada. verifique se foi feito e o que precisa corrigir: bl_info = {
    "name": "Rolling Ball Simulation Addon",
    "blender": (2, 80, 0),
    "category": "Physics",
}

import bpy
import math
from bpy.props import EnumProperty, FloatProperty, BoolProperty, IntProperty, StringProperty
import mathutils

# Predefined rail tracks
RAIL_TRACKS = [
    ("SPIRAL", "Spiral", "A spiral track"),
    ("LOOP", "Loop", "A loop track"),
    ("DROP", "Drop", "A drop track"),
    ("CORKSCREW", "Corkscrew", "A corkscrew track"),
    ("BANKED_TURN", "Banked Turn", "A banked turn track"),
    ("HILL", "Hill", "A hill track"),
    ("TWIST", "Twist", "A twist track"),
    ("HELIX", "Helix", "A helix track"),
    ("SWITCHBACK", "Switchback", "A switchback track"),
    ("MULTI_LOOP", "Multi-Loop", "A multi-loop track"),
    ("CUBIC_SPIRAL", "Cubic Spiral", "A cubic spiral track"),
    ("SINE_WAVE", "Sine Wave", "A sine wave track"),
    ("PARABOLA", "Parabola", "A parabolic track"),
    ("ARC", "Arc", "An arc track"),
    ("HELICAL_TWIST", "Helical Twist", "A helical twist track"),
    ("SLOPE", "Slope", "A slope track"),
    ("HELICAL_DROP", "Helical Drop", "A helical drop track"),
    ("TOWER_OF_TERROR", "Tower of Terror", "A tower of terror track"),
    ("VERTICAL_LOOP", "Vertical Loop", "A vertical loop track"),
    ("CIRCLE", "Circle", "A circular track"),
]

def create_spiral(radius=1, height=5, turns=2):
    curve_data = bpy.data.curves.new(name="SpiralCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * turns * t
        z = height * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("SpiralRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_loop(radius=1, height=2):
    curve_data = bpy.data.curves.new(name="LoopCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = True
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        z = height * (0.5 + 0.5 * math.cos(2 * math.pi * t))
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("LoopRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_drop(radius=1, height=5):
    curve_data = bpy.data.curves.new(name="DropCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        x = radius * math.cos(2 * math.pi * t)
        y = radius * math.sin(2 * math.pi * t)
        z = height * (1 - t)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("DropRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_corkscrew(radius=1, height=5, turns=2):
    curve_data = bpy.data.curves.new(name="CorkscrewCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * turns * t
        z = height * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("CorkscrewRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_banked_turn(radius=1, height=2, angle=45):
    curve_data = bpy.data.curves.new(name="BankedTurnCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = True
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        z = height * (0.5 + 0.5 * math.cos(2 * math.pi * t))
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    # Apply banking transformation
    mat = mathutils.Matrix.Rotation(math.radians(angle), 4, 'Z')
    for point in points:
        point.co = mat @ mathutils.Vector(point.co)
        point.handle_left = mat @ mathutils.Vector(point.handle_left)
        point.handle_right = mat @ mathutils.Vector(point.handle_right)

    obj = bpy.data.objects.new("BankedTurnRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_hill(radius=1, height=5):
    curve_data = bpy.data.curves.new(name="HillCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        x = radius * t
        y = 0
        z = height * (1 - (t - 0.5) ** 2)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("HillRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_twist(radius=1, height=5, turns=2):
    curve_data = bpy.data.curves.new(name="TwistCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * turns * t
        z = height * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    # Apply twist transformation
    mat = mathutils.Matrix.Rotation(math.radians(360 * t), 4, 'Z')
    for point in points:
        point.co = mat @ mathutils.Vector(point.co)
        point.handle_left = mat @ mathutils.Vector(point.handle_left)
        point.handle_right = mat @ mathutils.Vector(point.handle_right)

    obj = bpy.data.objects.new("TwistRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_helix(radius=1, height=5, turns=2):
    curve_data = bpy.data.curves.new(name="HelixCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * turns * t
        z = height * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("HelixRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_switchback(radius=1, height=5):
    curve_data = bpy.data.curves.new(name="SwitchbackCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        if t < 0.5:
            angle = 2 * math.pi * t
            z = height * t
            x = radius * math.cos(angle)
            y = radius * math.sin(angle)
        else:
            angle = 2 * math.pi * (1 - t)
            z = height * (1 - t)
            x = radius * math.cos(angle)
            y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("SwitchbackRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_multi_loop(radius=1, height=5, loops=3):
    curve_data = bpy.data.curves.new(name="MultiLoopCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = True
    num_points = 100 * loops
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        z = height * (0.5 + 0.5 * math.cos(2 * math.pi * t))
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("MultiLoopRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_cubic_spiral(radius=1, height=5, turns=2):
    curve_data = bpy.data.curves.new(name="CubicSpiralCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * turns * t
        z = height * t ** 3
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("CubicSpiralRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_sine_wave(radius=1, height=5, waves=2):
    curve_data = bpy.data.curves.new(name="SineWaveCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        x = radius * t
        y = 0
        z = height * math.sin(2 * math.pi * waves * t)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("SineWaveRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_parabola(radius=1, height=5):
    curve_data = bpy.data.curves.new(name="ParabolaCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        x = radius * t
        y = 0
        z = height * (t - 0.5) ** 2
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("ParabolaRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_arc(radius=1, height=5):
    curve_data = bpy.data.curves.new(name="ArcCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = math.pi * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        z = height * t
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("ArcRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_helical_twist(radius=1, height=5, turns=2):
    curve_data = bpy.data.curves.new(name="HelicalTwistCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * turns * t
        z = height * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    # Apply twist transformation
    mat = mathutils.Matrix.Rotation(math.radians(360 * t), 4, 'Z')
    for point in points:
        point.co = mat @ mathutils.Vector(point.co)
        point.handle_left = mat @ mathutils.Vector(point.handle_left)
        point.handle_right = mat @ mathutils.Vector(point.handle_right)

    obj = bpy.data.objects.new("HelicalTwistRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_slope(radius=1, height=5):
    curve_data = bpy.data.curves.new(name="SlopeCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        x = radius * t
        y = 0
        z = height * t
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("SlopeRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_helical_drop(radius=1, height=5, turns=2):
    curve_data = bpy.data.curves.new(name="HelicalDropCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * turns * t
        z = height * (1 - t)
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("HelicalDropRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_tower_of_terror(radius=1, height=5):
    curve_data = bpy.data.curves.new(name="TowerOfTerrorCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = False
    num_points = 100
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * t
        z = height * (1 - t)
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("TowerOfTerrorRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_vertical_loop(radius=1, height=5):
    curve_data = bpy.data.curves.new(name="VerticalLoopCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = True
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        z = height * (0.5 + 0.5 * math.cos(2 * math.pi * t))
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("VerticalLoopRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def create_circle(radius=1):
    curve_data = bpy.data.curves.new(name="CircleCurve", type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.1
    curve_data.bevel_resolution = 4

    spline = curve_data.splines.new('BEZIER')
    spline.use_cyclic_u = True
    num_points = 50
    points = spline.bezier_points
    points.add(num_points - 1)

    for i in range(num_points):
        t = i / (num_points - 1)
        angle = 2 * math.pi * t
        x = radius * math.cos(angle)
        y = radius * math.sin(angle)
        z = 0
        points[i].co = (x, y, z)
        points[i].handle_left_type = 'AUTO'
        points[i].handle_right_type = 'AUTO'

    obj = bpy.data.objects.new("CircleRail", curve_data)
    bpy.context.collection.objects.link(obj)
    return obj

def add_rail(track_type):
    if track_type == 'SPIRAL':
        rail = create_spiral()
    elif track_type == 'LOOP':
        rail = create_loop()
    elif track_type == 'DROP':
        rail = create_drop()
    elif track_type == 'CORKSCREW':
        rail = create_corkscrew()
    elif track_type == 'BANKED_TURN':
        rail = create_banked_turn()
    elif track_type == 'HILL':
        rail = create_hill()
    elif track_type == 'TWIST':
        rail = create_twist()
    elif track_type == 'HELIX':
        rail = create_helix()
    elif track_type == 'SWITCHBACK':
        rail = create_switchback()
    elif track_type == 'MULTI_LOOP':
        rail = create_multi_loop()
    elif track_type == 'CUBIC_SPIRAL':
        rail = create_cubic_spiral()
    elif track_type == 'SINE_WAVE':
        rail = create_sine_wave()
    elif track_type == 'PARABOLA':
        rail = create_parabola()
    elif track_type == 'ARC':
        rail = create_arc()
    elif track_type == 'HELICAL_TWIST':
        rail = create_helical_twist()
    elif track_type == 'SLOPE':
        rail = create_slope()
    elif track_type == 'HELICAL_DROP':
        rail = create_helical_drop()
    elif track_type == 'TOWER_OF_TERROR':
        rail = create_tower_of_terror()
    elif track_type == 'VERTICAL_LOOP':
        rail = create_vertical_loop()
    elif track_type == 'CIRCLE':
        rail = create_circle()
    else:
        return None

    if rail:
        rail.name = f"Rail_{track_type}_{len([obj for obj in bpy.data.objects if obj.name.startswith(f"Rail_{track_type}_")])}"
        add_rigid_body_to_object(rail, type='PASSIVE')
    return rail

def add_ball(location):
    bpy.ops.mesh.primitive_uv_sphere_add(radius=bpy.context.scene.ball_radius, location=location)
    ball = bpy.context.object
    ball.name = f"RollingBall_{len([obj for obj in bpy.data.objects if obj.name.startswith("RollingBall_")])}"
    add_rigid_body_to_object(ball, type='ACTIVE')
    return ball

def add_rigid_body_to_object(obj, type='PASSIVE'):
    # Ensure we are in Object Mode
    if bpy.context.mode != 'OBJECT':
        bpy.ops.object.mode_set(mode='OBJECT')

    # Deselect all objects
    bpy.ops.object.select_all(action='DESELECT')

    # Select and make the object active
    obj.select_set(True)
    bpy.context.view_layer.objects.active = obj

    # Add rigid body physics
    bpy.ops.rigidbody.object_add(type=type)
    if type == 'PASSIVE':
        obj.rigid_body.collision_shape = 'MESH'
    elif type == 'ACTIVE':
        obj.rigid_body.collision_shape = 'SPHERE'
    obj.rigid_body.friction = bpy.context.scene.ball_friction
    obj.rigid_body.restitution = bpy.context.scene.ball_restitution
    obj.rigid_body.linear_damping = bpy.context.scene.ball_linear_damping
    obj.rigid_body.angular_damping = bpy.context.scene.ball_angular_damping
    obj.rigid_body.mass = bpy.context.scene.ball_mass

def set_simulation_gravity(gravity):
    scene = bpy.context.scene
    if scene.rigidbody_world:
        scene.rigidbody_world.point_cache.frame_start = 1
        scene.rigidbody_world.point_cache.frame_end = 250
        scene.rigidbody_world.time_scale = bpy.context.scene.simulation_speed
        scene.rigidbody_world.settings.effector_weights.all = gravity / -9.81

def start_simulation():
    scene = bpy.context.scene
    set_simulation_gravity(scene.simulation_gravity)
    bpy.ops.screen.animation_play()

def pause_simulation():
    bpy.ops.screen.animation_cancel()

def reset_simulation():
    scene = bpy.context.scene
    pause_simulation()
    bpy.ops.screen.frame_jump(end=False)
    for obj in bpy.data.objects:
        if obj.rigid_body:
            obj.rigid_body.kinematic = True
            obj.location = obj.rigid_body.world_center_of_mass
            obj.rotation_euler = (0, 0, 0)
            obj.keyframe_insert(data_path="location", frame=1)
            obj.keyframe_insert(data_path="rotation_euler", frame=1)
            obj.rigid_body.kinematic = False

class PHYSICS_PT_rolling_ball(bpy.types.Panel):
    bl_label = "Rolling Ball Simulation"
    bl_idname = "PHYSICS_PT_rolling_ball"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Physics'

    def draw(self, context):
        layout = self.layout
        scene = context.scene

        layout.prop(scene, "selected_track")
        layout.operator("physics.add_rail", text="Add Rail", icon='MOD_CURVE')
        layout.operator("physics.add_ball", text="Add Ball", icon='SPHERE')
        layout.separator()
        layout.operator("physics.start_simulation", text="Start Simulation", icon='PLAY')
        layout.operator("physics.pause_simulation", text="Pause Simulation", icon='PAUSE')
        layout.operator("physics.reset_simulation", text="Reset Simulation", icon='REW')
        layout.separator()

        box = layout.box()
        box.label(text="Simulation Controls", icon='PHYSICS')
        box.prop(scene, "simulation_gravity", text="Gravity", icon='FORCE_GRAVITY')
        box.prop(scene, "simulation_speed", text="Speed", icon='TIME')
        layout.separator()

        box = layout.box()
        box.label(text="Ball Parameters", icon='SPHERE')
        box.prop(scene, "ball_radius", text="Radius", icon='MESH_UVSPHERE')
        box.prop(scene, "ball_mass", text="Mass", icon='MOD_PHYSICS')
        box.prop(scene, "ball_friction", text="Friction", icon='MOD_SMOOTH')
        box.prop(scene, "ball_restitution", text="Restitution", icon='SNAP_INCREMENT')
        box.prop(scene, "ball_linear_damping", text="Linear Damping", icon='MOD_PHYSICS')
        box.prop(scene, "ball_angular_damping", text="Angular Damping", icon='MOD_PHYSICS')

class PHYSICS_OT_add_rail(bpy.types.Operator):
    bl_idname = "physics.add_rail"
    bl_label = "Add Rail"
    bl_description = "Add a predefined rail track"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        scene = context.scene
        rail = add_rail(scene.selected_track)
        if rail:
            rail.name = f"Rail_{scene.selected_track}_{len([obj for obj in bpy.data.objects if obj.name.startswith(f"Rail_{scene.selected_track}_")])}"
            add_rigid_body_to_object(rail, type='PASSIVE')
        return {'FINISHED'}

class PHYSICS_OT_add_ball(bpy.types.Operator):
    bl_idname = "physics.add_ball"
    bl_label = "Add Ball"
    bl_description = "Add a ball at the start of the selected rail"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        scene = context.scene
        rail = bpy.data.objects.get(f"Rail_{scene.selected_track}_1")
        if rail and rail.data.splines:
            start_point = rail.matrix_world @ rail.data.splines[0].bezier_points[0].co
            ball_offset = mathutils.Vector((0, 0, bpy.context.scene.ball_radius * 1.1))
            ball_location = start_point + ball_offset
            ball = add_ball(ball_location)
        return {'FINISHED'}

class PHYSICS_OT_start_simulation(bpy.types.Operator):
    bl_idname = "physics.start_simulation"
    bl_label = "Start Simulation"
    bl_description = "Start the physics simulation"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        start_simulation()
        return {'FINISHED'}

class PHYSICS_OT_pause_simulation(bpy.types.Operator):
    bl_idname = "physics.pause_simulation"
    bl_label = "Pause Simulation"
    bl_description = "Pause the physics simulation"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        pause_simulation()
        return {'FINISHED'}

class PHYSICS_OT_reset_simulation(bpy.types.Operator):
    bl_idname = "physics.reset_simulation"
    bl_label = "Reset Simulation"
    bl_description = "Reset the physics simulation"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        reset_simulation()
        return {'FINISHED'}

def register():
    bpy.utils.register_class(PHYSICS_PT_rolling_ball)
    bpy.utils.register_class(PHYSICS_OT_add_rail)
    bpy.utils.register_class(PHYSICS_OT_add_ball)
    bpy.utils.register_class(PHYSICS_OT_start_simulation)
    bpy.utils.register_class(PHYSICS_OT_pause_simulation)
    bpy.utils.register_class(PHYSICS_OT_reset_simulation)

    bpy.types.Scene.selected_track = EnumProperty(
        name="Selected Track",
        description="Choose a rail track",
        items=RAIL_TRACKS,
        default='SPIRAL',
    )

    bpy.types.Scene.ball_radius = FloatProperty(
        name="Ball Radius",
        description="Radius of the ball",
        default=0.5,
        min=0.1,
        max=1.0,
    )

    bpy.types.Scene.ball_mass = FloatProperty(
        name="Ball Mass",
        description="Mass of the ball",
        default=1.0,
        min=0.1,
        max=10.0,
    )

    bpy.types.Scene.ball_friction = FloatProperty(
        name="Ball Friction",
        description="Friction of the ball",
        default=0.5,
        min=0.0,
        max=1.0,
    )

    bpy.types.Scene.ball_restitution = FloatProperty(
        name="Ball Restitution",
        description="Restitution of the ball",
        default=0.0,
        min=0.0,
        max=1.0,
    )

    bpy.types.Scene.ball_linear_damping = FloatProperty(
        name="Linear Damping",
        description="Linear damping of the ball",
        default=0.1,
        min=0.0,
        max=1.0,
    )

    bpy.types.Scene.ball_angular_damping = FloatProperty(
        name="Angular Damping",
        description="Angular damping of the ball",
        default=0.1,
        min=0.0,
        max=1.0,
    )

    bpy.types.Scene.simulation_gravity = FloatProperty(
        name="Simulation Gravity",
        description="Simulation gravity",
        default=-9.81,
        min=-10.0,
        max=10.0,
    )

    bpy.types.Scene.simulation_speed = FloatProperty(
        name="Simulation Speed",
        description="Simulation speed multiplier",
        default=1.0,
        min=0.1,
        max=10.0,
    )

def unregister():
    bpy.utils.unregister_class(PHYSICS_PT_rolling_ball)
    bpy.utils.unregister_class(PHYSICS_OT_add_rail)
    bpy.utils.unregister_class(PHYSICS_OT_add_ball)
    bpy.utils.unregister_class(PHYSICS_OT_start_simulation)
    bpy.utils.unregister_class(PHYSICS_OT_pause_simulation)
    bpy.utils.unregister_class(PHYSICS_OT_reset_simulation)

    del bpy.types.Scene.selected_track
    del bpy.types.Scene.ball_radius
    del bpy.types.Scene.ball_mass
    del bpy.types.Scene.ball_friction
    del bpy.types.Scene.ball_restitution
    del bpy.types.Scene.ball_linear_damping
    del bpy.types.Scene.ball_angular_damping
    del bpy.types.Scene.simulation_gravity
    del bpy.types.Scene.simulation_speed

if __name__ == "__main__":
    register()