feat(rcf): added client snap
This commit is contained in:
@ -20,12 +20,13 @@ server = None
|
|||||||
context = None
|
context = None
|
||||||
|
|
||||||
|
|
||||||
COLOR_TABLE = [(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1),(0, 0.5, 1, 1),(0.5, 0, 1, 1)]
|
COLOR_TABLE = [(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1),
|
||||||
|
(0, 0.5, 1, 1), (0.5, 0, 1, 1)]
|
||||||
NATIVE_TYPES = (
|
NATIVE_TYPES = (
|
||||||
bpy.types.IntProperty,
|
int,
|
||||||
bpy.types.FloatProperty,
|
float,
|
||||||
bpy.types.BoolProperty,
|
bool,
|
||||||
bpy.types.StringProperty,
|
string,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ def from_bpy(value):
|
|||||||
pass # TODO: Collection replication
|
pass # TODO: Collection replication
|
||||||
elif value_type is mathutils.Euler:
|
elif value_type is mathutils.Euler:
|
||||||
value_casted = [value.x, value.y, value.z]
|
value_casted = [value.x, value.y, value.z]
|
||||||
elif value_type is NATIVE_TYPES:
|
elif value_type in NATIVE_TYPES:
|
||||||
value_casted = value
|
value_casted = value
|
||||||
|
|
||||||
return str(value.__class__.__name__), value_casted
|
return str(value.__class__.__name__), value_casted
|
||||||
@ -405,11 +406,12 @@ class session_settings(bpy.types.PropertyGroup):
|
|||||||
is_running = bpy.props.BoolProperty(name="is_running", default=False)
|
is_running = bpy.props.BoolProperty(name="is_running", default=False)
|
||||||
hide_users = bpy.props.BoolProperty(name="is_running", default=False)
|
hide_users = bpy.props.BoolProperty(name="is_running", default=False)
|
||||||
hide_settings = bpy.props.BoolProperty(name="hide_settings", default=False)
|
hide_settings = bpy.props.BoolProperty(name="hide_settings", default=False)
|
||||||
hide_properties = bpy.props.BoolProperty(name="hide_properties", default=True)
|
hide_properties = bpy.props.BoolProperty(
|
||||||
|
name="hide_properties", default=True)
|
||||||
update_frequency = bpy.props.FloatProperty(
|
update_frequency = bpy.props.FloatProperty(
|
||||||
name="update_frequency", default=0.008)
|
name="update_frequency", default=0.008)
|
||||||
active_object = bpy.props.PointerProperty(name="active_object",type=bpy.types.Object)
|
active_object = bpy.props.PointerProperty(
|
||||||
|
name="active_object", type=bpy.types.Object)
|
||||||
|
|
||||||
|
|
||||||
class session_draw_clients(bpy.types.Operator):
|
class session_draw_clients(bpy.types.Operator):
|
||||||
@ -483,7 +485,8 @@ class session_draw_clients(bpy.types.Operator):
|
|||||||
|
|
||||||
bbox_corners = [ob.matrix_world @ mathutils.Vector(corner) for corner in ob.bound_box]
|
bbox_corners = [ob.matrix_world @ mathutils.Vector(corner) for corner in ob.bound_box]
|
||||||
|
|
||||||
coords= [(point.x,point.y,point.z) for point in bbox_corners]
|
coords = [(point.x, point.y, point.z)
|
||||||
|
for point in bbox_corners]
|
||||||
|
|
||||||
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||||
batch = batch_for_shader(
|
batch = batch_for_shader(
|
||||||
@ -508,7 +511,6 @@ class session_draw_clients(bpy.types.Operator):
|
|||||||
(shader, batch, (values.body[1], values.id.decode()), COLOR_TABLE[index]))
|
(shader, batch, (values.body[1], values.id.decode()), COLOR_TABLE[index]))
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
|
||||||
def draw3d_callback(self):
|
def draw3d_callback(self):
|
||||||
|
|
||||||
bgl.glLineWidth(3)
|
bgl.glLineWidth(3)
|
||||||
@ -529,6 +531,7 @@ class session_draw_clients(bpy.types.Operator):
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def is_object_selected(self, obj):
|
def is_object_selected(self, obj):
|
||||||
# TODO: function to find occurence
|
# TODO: function to find occurence
|
||||||
global client
|
global client
|
||||||
@ -570,12 +573,12 @@ class session_draw_clients(bpy.types.Operator):
|
|||||||
object.hide_select = False
|
object.hide_select = False
|
||||||
|
|
||||||
# Active object bounding box
|
# Active object bounding box
|
||||||
|
|
||||||
if len(context.selected_objects) > 0:
|
if len(context.selected_objects) > 0:
|
||||||
if session.active_object is not context.selected_objects[0] or session.active_object.is_evaluated:
|
if session.active_object is not context.selected_objects[0] or session.active_object.is_evaluated:
|
||||||
session.active_object = context.selected_objects[0]
|
session.active_object = context.selected_objects[0]
|
||||||
key = "net/objects/{}".format(client.id.decode())
|
key = "net/objects/{}".format(client.id.decode())
|
||||||
client.push_update(key, 'object', session.active_object.name)
|
client.push_update(
|
||||||
|
key, 'object', session.active_object.name)
|
||||||
elif len(context.selected_objects) == 0 and session.active_object:
|
elif len(context.selected_objects) == 0 and session.active_object:
|
||||||
session.active_object = None
|
session.active_object = None
|
||||||
key = "net/objects/{}".format(client.id.decode())
|
key = "net/objects/{}".format(client.id.decode())
|
||||||
@ -595,6 +598,32 @@ class session_draw_clients(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class session_snapview(bpy.types.Operator):
|
||||||
|
bl_idname = "session.snapview"
|
||||||
|
bl_label = "draw clients"
|
||||||
|
bl_description = "Description that shows in blender tooltips"
|
||||||
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
|
target_client = bpy.props.StringProperty()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
global client
|
||||||
|
|
||||||
|
area, region, rv3d = view3d_find()
|
||||||
|
|
||||||
|
for k,v in client.property_map.items():
|
||||||
|
if v.mtype == 'client' and v.id.decode() == self.target_client:
|
||||||
|
rv3d.view_location = v.body[1]
|
||||||
|
rv3d.view_distance = 10.0
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
pass
|
||||||
# TODO: Rename to match official blender convention
|
# TODO: Rename to match official blender convention
|
||||||
classes = (
|
classes = (
|
||||||
session_join,
|
session_join,
|
||||||
@ -604,6 +633,7 @@ classes = (
|
|||||||
session_settings,
|
session_settings,
|
||||||
session_remove_property,
|
session_remove_property,
|
||||||
session_draw_clients,
|
session_draw_clients,
|
||||||
|
session_snapview,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,6 +80,9 @@ class SessionUsersPanel(bpy.types.Panel):
|
|||||||
info = "(self)"
|
info = "(self)"
|
||||||
# detail_item_box = item_box.row()
|
# detail_item_box = item_box.row()
|
||||||
detail_item_box.label(text="{} {}".format(values.id.decode(),info))
|
detail_item_box.label(text="{} {}".format(values.id.decode(),info))
|
||||||
|
|
||||||
|
if net_operators.client.id.decode() not in key:
|
||||||
|
detail_item_box.operator("session.snapview",text="",icon='VIEW_CAMERA').target_client = values.id.decode()
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
else:
|
else:
|
||||||
row.label(text="Empty")
|
row.label(text="Empty")
|
||||||
|
Reference in New Issue
Block a user