From f2f0e1db7e1976fdfc947932acb531556bb67388 Mon Sep 17 00:00:00 2001 From: x-o-i-o-x <103693092+x-o-i-o-x@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:20:48 +0200 Subject: [PATCH] paintListener working --- __init__.py | 6 +++--- paintListener.py | 14 ++++---------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/__init__.py b/__init__.py index 58218f5..4340e5d 100644 --- a/__init__.py +++ b/__init__.py @@ -12,9 +12,9 @@ bl_info = { } from . import ( + ui, paintListener, paintModifier, - ui, preferences, ) @@ -22,9 +22,9 @@ import bpy # Blender Python API # Register and Unregister Classes module_tuple = ( - #paintListener, - #paintModifier, ui, + paintListener, + #paintModifier, #preferences, ) diff --git a/paintListener.py b/paintListener.py index 860c8fa..85d36b0 100644 --- a/paintListener.py +++ b/paintListener.py @@ -81,7 +81,6 @@ class vPainterOperator(bpy.types.Operator): region = next((r for r in context.area.regions if r.type == 'WINDOW'), None) # Get mouse position in 3D space -# mouse_coords = (event.mouse_region_x, event.mouse_region_y) # Adjust mouse coordinates to match the main region mouse_coords = ( event.mouse_x - region.x, @@ -90,13 +89,6 @@ class vPainterOperator(bpy.types.Operator): view_vector = bpy_extras.view3d_utils.region_2d_to_vector_3d(region, rv3d, mouse_coords) ray_origin = bpy_extras.view3d_utils.region_2d_to_origin_3d(region, rv3d, mouse_coords) -# print(mouse_coords) -# print(view_vector) -# print(ray_origin) - - # Perform a ray cast to find the hit location -# obj = context.object - # Ensure there is a selected object selected_objects = context.selected_objects if not selected_objects: @@ -106,6 +98,7 @@ class vPainterOperator(bpy.types.Operator): # Use the first selected object obj = selected_objects[0] + # Perform a ray cast to find the hit location if obj.type == 'MESH': matrix_world = obj.matrix_world matrix_world_inv = matrix_world.inverted() @@ -119,7 +112,6 @@ class vPainterOperator(bpy.types.Operator): result, location, normal, index = obj.ray_cast( ray_origin_local, ray_origin_local + ray_direction_local * 1000 ) -# print(f"Ray cast result: {result}, Location (local): {location_local}, Normal (local): {normal_local}") print(normal) if result: @@ -148,6 +140,8 @@ def brushstroke_callback(scene, depsgraph): def register(): bpy.utils.register_class(vPainterOperator) + bpy.types.Scene.normal_color_global = bpy.props.FloatVectorProperty(size=3, default=(1.0, 1.0, 1.0)) def unregister(): - bpy.utils.unregister_class(vPainterOperator) \ No newline at end of file + bpy.utils.unregister_class(vPainterOperator) + del bpy.types.Scene.normal_color_global \ No newline at end of file