Merge branch 'master' into animation-support
This commit is contained in:
commit
d12fe9dd70
@ -14,8 +14,11 @@ __all__ = [
|
||||
'bl_armature',
|
||||
'bl_action',
|
||||
'bl_world',
|
||||
'bl_metaball'
|
||||
]
|
||||
'bl_metaball',
|
||||
'bl_lattice',
|
||||
'bl_lightprobe',
|
||||
'bl_speaker'
|
||||
] # Order here defines execution order
|
||||
|
||||
from . import *
|
||||
from ..libs.replication.replication.data import ReplicatedDataFactory
|
||||
|
@ -43,6 +43,13 @@ class BlCurve(BlDatablock):
|
||||
spline_data['bezier_points'] = dumper.dump(spline.bezier_points)
|
||||
spline_data['type'] = dumper.dump(spline.type)
|
||||
data['splines'][index] = spline_data
|
||||
|
||||
if isinstance(pointer,'TextCurve'):
|
||||
data['type'] = 'TEXT'
|
||||
if isinstance(pointer,'SurfaceCurve'):
|
||||
data['type'] = 'SURFACE'
|
||||
if isinstance(pointer,'TextCurve'):
|
||||
data['type'] = 'CURVE'
|
||||
return data
|
||||
|
||||
def resolve(self):
|
||||
|
54
multi_user/bl_types/bl_lattice.py
Normal file
54
multi_user/bl_types/bl_lattice.py
Normal file
@ -0,0 +1,54 @@
|
||||
import bpy
|
||||
import mathutils
|
||||
|
||||
from .. import utils
|
||||
from .bl_datablock import BlDatablock
|
||||
|
||||
|
||||
class BlLattice(BlDatablock):
|
||||
def load(self, data, target):
|
||||
utils.dump_anything.load(target, data)
|
||||
|
||||
for point in data['points']:
|
||||
utils.dump_anything.load(target.points[point], data["points"][point])
|
||||
def construct(self, data):
|
||||
return bpy.data.lattices.new(data["name"])
|
||||
|
||||
def dump(self, pointer=None):
|
||||
assert(pointer)
|
||||
|
||||
dumper = utils.dump_anything.Dumper()
|
||||
dumper.depth = 3
|
||||
dumper.include_filter = [
|
||||
"name",
|
||||
'type',
|
||||
'points_u',
|
||||
'points_v',
|
||||
'points_w',
|
||||
'interpolation_type_u',
|
||||
'interpolation_type_v',
|
||||
'interpolation_type_w',
|
||||
'use_outside',
|
||||
'points',
|
||||
'co',
|
||||
'weight_softbody',
|
||||
'co_deform'
|
||||
]
|
||||
data = dumper.dump(pointer)
|
||||
|
||||
return data
|
||||
|
||||
def resolve(self):
|
||||
self.pointer = utils.find_from_attr('uuid', self.uuid, bpy.data.lattices)
|
||||
|
||||
def is_valid(self):
|
||||
return bpy.data.lattices.get(self.data['name'])
|
||||
|
||||
|
||||
bl_id = "lattices"
|
||||
bl_class = bpy.types.Lattice
|
||||
bl_rep_class = BlLattice
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_icon = 'LATTICE_DATA'
|
49
multi_user/bl_types/bl_lightprobe.py
Normal file
49
multi_user/bl_types/bl_lightprobe.py
Normal file
@ -0,0 +1,49 @@
|
||||
import bpy
|
||||
import mathutils
|
||||
|
||||
from .. import utils
|
||||
from .bl_datablock import BlDatablock
|
||||
|
||||
|
||||
class BlLightProbe(BlDatablock):
|
||||
def load(self, data, target):
|
||||
utils.dump_anything.load(target, data)
|
||||
|
||||
def construct(self, data):
|
||||
return bpy.data.lightprobes.new(data["name"])
|
||||
|
||||
def dump(self, pointer=None):
|
||||
assert(pointer)
|
||||
|
||||
dumper = utils.dump_anything.Dumper()
|
||||
dumper.depth = 1
|
||||
dumper.include_filter = [
|
||||
"name",
|
||||
'influence_type',
|
||||
'influence_distance',
|
||||
'falloff',
|
||||
'intensity',
|
||||
'clip_start',
|
||||
'clip_end',
|
||||
'visibility_collection',
|
||||
'use_custom_parallax',
|
||||
'parallax_type',
|
||||
'parallax_distance',
|
||||
]
|
||||
|
||||
return dumper.dump(pointer)
|
||||
|
||||
def resolve(self):
|
||||
self.pointer = utils.find_from_attr('uuid', self.uuid, bpy.data.lattices)
|
||||
|
||||
def is_valid(self):
|
||||
return bpy.data.lattices.get(self.data['name'])
|
||||
|
||||
|
||||
bl_id = "lightprobes"
|
||||
bl_class = bpy.types.LightProbe
|
||||
bl_rep_class = BlLightProbe
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_icon = 'LIGHTPROBE_GRID'
|
@ -62,6 +62,14 @@ class BlObject(BlDatablock):
|
||||
pointer = bpy.data.grease_pencils[data["data"]]
|
||||
elif data["data"] in bpy.data.curves.keys():
|
||||
pointer = bpy.data.curves[data["data"]]
|
||||
elif data["data"] in bpy.data.lattices.keys():
|
||||
pointer = bpy.data.lattices[data["data"]]
|
||||
elif data["data"] in bpy.data.speakers.keys():
|
||||
pointer = bpy.data.speakers[data["data"]]
|
||||
elif data["data"] in bpy.data.lightprobes.keys():
|
||||
pass
|
||||
# bpy need to support correct lightprobe creation from python
|
||||
# pointer = bpy.data.lightprobes[data["data"]]
|
||||
|
||||
instance = bpy.data.objects.new(data["name"], pointer)
|
||||
instance.uuid = self.uuid
|
||||
|
50
multi_user/bl_types/bl_speaker.py
Normal file
50
multi_user/bl_types/bl_speaker.py
Normal file
@ -0,0 +1,50 @@
|
||||
import bpy
|
||||
import mathutils
|
||||
|
||||
from .. import utils
|
||||
from .bl_datablock import BlDatablock
|
||||
|
||||
|
||||
class BlSpeaker(BlDatablock):
|
||||
def load(self, data, target):
|
||||
utils.dump_anything.load(target, data)
|
||||
|
||||
def construct(self, data):
|
||||
return bpy.data.speakers.new(data["name"])
|
||||
|
||||
def dump(self, pointer=None):
|
||||
assert(pointer)
|
||||
|
||||
dumper = utils.dump_anything.Dumper()
|
||||
dumper.depth = 1
|
||||
dumper.include_filter = [
|
||||
"muted",
|
||||
'volume',
|
||||
'name',
|
||||
'pitch',
|
||||
'volume_min',
|
||||
'volume_max',
|
||||
'attenuation',
|
||||
'distance_max',
|
||||
'distance_reference',
|
||||
'cone_angle_outer',
|
||||
'cone_angle_inner',
|
||||
'cone_volume_outer'
|
||||
]
|
||||
|
||||
return dumper.dump(pointer)
|
||||
|
||||
def resolve(self):
|
||||
self.pointer = utils.find_from_attr('uuid', self.uuid, bpy.data.lattices)
|
||||
|
||||
def is_valid(self):
|
||||
return bpy.data.lattices.get(self.data['name'])
|
||||
|
||||
|
||||
bl_id = "speakers"
|
||||
bl_class = bpy.types.Speaker
|
||||
bl_rep_class = BlSpeaker
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_icon = 'SPEAKER'
|
@ -20,7 +20,11 @@ from . import bl_types, delayable, environment, presence, ui, utils
|
||||
from .libs.replication.replication.data import ReplicatedDataFactory
|
||||
from .libs.replication.replication.exception import NonAuthorizedOperationError
|
||||
from .libs.replication.replication.interface import Session
|
||||
from .libs.replication.replication.constants import FETCHED
|
||||
from .libs.replication.replication.constants import (
|
||||
STATE_ACTIVE,
|
||||
STATE_INITIAL,
|
||||
STATE_SYNCING,
|
||||
FETCHED)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.ERROR)
|
||||
@ -376,6 +380,12 @@ classes = (
|
||||
SessionCommit,
|
||||
ApplyArmatureOperator,
|
||||
)
|
||||
@persistent
|
||||
def load_pre_handler(dummy):
|
||||
global client
|
||||
|
||||
if client and client.state in [STATE_ACTIVE, STATE_SYNCING]:
|
||||
bpy.ops.session.stop()
|
||||
|
||||
|
||||
def register():
|
||||
@ -383,6 +393,10 @@ def register():
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
bpy.app.handlers.load_pre.append(load_pre_handler)
|
||||
>>>>>>> master
|
||||
|
||||
def unregister():
|
||||
global client
|
||||
@ -395,6 +409,8 @@ def unregister():
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
|
||||
bpy.app.handlers.load_pre.remove(load_pre_handler)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
@ -56,6 +56,18 @@ def get_target_far(region, rv3d, coord, distance):
|
||||
|
||||
return [target.x, target.y, target.z]
|
||||
|
||||
def get_default_bbox(obj, radius):
|
||||
coords = [
|
||||
(-radius, -radius, -radius), (+radius, -radius, -radius),
|
||||
(-radius, +radius, -radius), (+radius, +radius, -radius),
|
||||
(-radius, -radius, +radius), (+radius, -radius, +radius),
|
||||
(-radius, +radius, +radius), (+radius, +radius, +radius)]
|
||||
|
||||
base = obj.matrix_world
|
||||
bbox_corners = [base @ mathutils.Vector(corner) for corner in coords]
|
||||
|
||||
return [(point.x, point.y, point.z)
|
||||
for point in bbox_corners]
|
||||
|
||||
def get_client_cam_points():
|
||||
area, region, rv3d = view3d_find()
|
||||
@ -131,7 +143,7 @@ class User():
|
||||
def update_presence(self, context):
|
||||
global renderer
|
||||
|
||||
if 'renderer' in globals():
|
||||
if 'renderer' in globals() and hasattr(renderer, 'run'):
|
||||
if self.enable_presence:
|
||||
renderer.run()
|
||||
else:
|
||||
@ -183,7 +195,7 @@ class DrawFactory(object):
|
||||
self.d3d_items.clear()
|
||||
self.d2d_items.clear()
|
||||
|
||||
def flush_selection(self, user):
|
||||
def flush_selection(self, user=None):
|
||||
key_to_remove = []
|
||||
select_key = "{}_select".format(user) if user else "select"
|
||||
for k in self.d3d_items.keys():
|
||||
@ -213,35 +225,45 @@ class DrawFactory(object):
|
||||
|
||||
for select_ob in client_selection:
|
||||
drawable_key = "{}_select_{}".format(client_uuid, select_ob)
|
||||
indices = (
|
||||
(0, 1), (1, 2), (2, 3), (0, 3),
|
||||
(4, 5), (5, 6), (6, 7), (4, 7),
|
||||
(0, 4), (1, 5), (2, 6), (3, 7)
|
||||
)
|
||||
ob = utils.find_from_attr("uuid",select_ob,bpy.data.objects)
|
||||
|
||||
ob = utils.find_from_attr("uuid", select_ob, bpy.data.objects)
|
||||
if not ob:
|
||||
return
|
||||
|
||||
item_to_draw = []
|
||||
if ob.type == 'EMPTY':
|
||||
# Child case
|
||||
|
||||
# TODO: Child case
|
||||
# Collection instance case
|
||||
if ob.instance_collection:
|
||||
for obj in ob.instance_collection.objects:
|
||||
if obj.type == 'MESH':
|
||||
self.append_3d_item(
|
||||
self.append_3d_item(
|
||||
drawable_key,
|
||||
client_color,
|
||||
get_bb_coords_from_obj(obj, parent=ob),
|
||||
indices)
|
||||
|
||||
if ob.type == 'MESH':
|
||||
if ob.type in ['MESH','META']:
|
||||
indices = (
|
||||
(0, 1), (1, 2), (2, 3), (0, 3),
|
||||
(4, 5), (5, 6), (6, 7), (4, 7),
|
||||
(0, 4), (1, 5), (2, 6), (3, 7))
|
||||
|
||||
self.append_3d_item(
|
||||
drawable_key,
|
||||
client_color,
|
||||
get_bb_coords_from_obj(ob),
|
||||
indices)
|
||||
else:
|
||||
indices = (
|
||||
(0, 1), (0, 2), (1, 3), (2, 3),
|
||||
(4, 5), (4, 6), (5, 7), (6, 7),
|
||||
(0, 4), (1, 5), (2, 6), (3, 7))
|
||||
|
||||
self.append_3d_item(
|
||||
drawable_key,
|
||||
client_color,
|
||||
get_default_bbox(ob, ob.scale.x),
|
||||
indices)
|
||||
|
||||
def append_3d_item(self,key,color, coords, indices):
|
||||
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||
@ -279,6 +301,9 @@ class DrawFactory(object):
|
||||
def draw3d_callback(self):
|
||||
bgl.glLineWidth(1.5)
|
||||
bgl.glEnable(bgl.GL_DEPTH_TEST)
|
||||
bgl.glEnable(bgl.GL_BLEND)
|
||||
bgl.glEnable(bgl.GL_LINE_SMOOTH)
|
||||
|
||||
try:
|
||||
for shader, batch, color in self.d3d_items.values():
|
||||
shader.bind()
|
||||
|
Loading…
x
Reference in New Issue
Block a user