paintListener working
This commit is contained in:
parent
7ed6d0228c
commit
f2f0e1db7e
@ -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,
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
bpy.utils.unregister_class(vPainterOperator)
|
||||
del bpy.types.Scene.normal_color_global
|
Loading…
Reference in New Issue
Block a user