fix: error in utils
feat: mesh
This commit is contained in:
36
__init__.py
36
__init__.py
@ -9,20 +9,19 @@ bl_info = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
import addon_utils
|
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
from . import environment, utils
|
from . import environment
|
||||||
|
from . import utils
|
||||||
|
|
||||||
|
|
||||||
DEPENDENCIES = {
|
DEPENDENCIES = {
|
||||||
"zmq",
|
"zmq",
|
||||||
"umsgpack",
|
"umsgpack",
|
||||||
"yaml",
|
"yaml"
|
||||||
"esper"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -31,24 +30,24 @@ logging.basicConfig(level=logging.INFO)
|
|||||||
|
|
||||||
# UTILITY FUNCTIONS
|
# UTILITY FUNCTIONS
|
||||||
def client_list_callback(scene, context):
|
def client_list_callback(scene, context):
|
||||||
from operator import cli
|
# from operator import client
|
||||||
|
|
||||||
items = [("Common", "Common", "")]
|
# items = [("Common", "Common", "")]
|
||||||
|
|
||||||
username = bpy.context.window_manager.session.username
|
# username = bpy.context.window_manager.session.username
|
||||||
|
|
||||||
if cli:
|
# if cli:
|
||||||
client_keys = cli.list()
|
# client_keys = cli.list()
|
||||||
for k in client_keys:
|
# for k in client_keys:
|
||||||
if 'Client' in k[0]:
|
# if 'Client' in k[0]:
|
||||||
name = k[1]
|
# name = k[1]
|
||||||
|
|
||||||
if name == username:
|
# if name == username:
|
||||||
name += " (self)"
|
# name += " (self)"
|
||||||
|
|
||||||
items.append((name, name, ""))
|
# items.append((name, name, ""))
|
||||||
|
|
||||||
return items
|
return [("Common", "Common", "")]
|
||||||
|
|
||||||
|
|
||||||
def randomColor():
|
def randomColor():
|
||||||
@ -191,14 +190,13 @@ class SessionProps(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
ReplicatedDatablock,
|
ReplicatedDatablock,
|
||||||
SessionProps
|
SessionProps,
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
libs = os.path.dirname(os.path.abspath(__file__))+"\\libs\\replication"
|
libs = os.path.dirname(os.path.abspath(__file__))+"\\libs\\replication"
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
|
||||||
if libs not in sys.path:
|
if libs not in sys.path:
|
||||||
sys.path.append(libs)
|
sys.path.append(libs)
|
||||||
print(libs)
|
print(libs)
|
||||||
@ -211,8 +209,6 @@ def register():
|
|||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
bpy.types.ID.id = bpy.props.StringProperty(default="None")
|
|
||||||
bpy.types.ID.is_dirty = bpy.props.BoolProperty(default=False)
|
|
||||||
bpy.types.WindowManager.session = bpy.props.PointerProperty(
|
bpy.types.WindowManager.session = bpy.props.PointerProperty(
|
||||||
type=SessionProps)
|
type=SessionProps)
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class BlMesh(ReplicatedDatablock):
|
|||||||
f = mesh_buffer.faces.new(verts)
|
f = mesh_buffer.faces.new(verts)
|
||||||
f.material_index = data["polygons"][p]['material_index']
|
f.material_index = data["polygons"][p]['material_index']
|
||||||
|
|
||||||
if target is None and create:
|
if target is None:
|
||||||
target = bpy.data.meshes.new(data["name"])
|
target = bpy.data.meshes.new(data["name"])
|
||||||
|
|
||||||
mesh_buffer.to_mesh(target)
|
mesh_buffer.to_mesh(target)
|
||||||
@ -55,7 +55,7 @@ class BlMesh(ReplicatedDatablock):
|
|||||||
assert(pointer)
|
assert(pointer)
|
||||||
|
|
||||||
data = utils.dump_datablock(pointer, 2)
|
data = utils.dump_datablock(pointer, 2)
|
||||||
utils.dump_datablock_attibute(
|
utils.dump_datablock_attibutes(
|
||||||
pointer, ['name', 'polygons', 'edges', 'vertices', 'id'], 6, data)
|
pointer, ['name', 'polygons', 'edges', 'vertices', 'id'], 6, data)
|
||||||
|
|
||||||
# Fix material index
|
# Fix material index
|
||||||
@ -69,5 +69,5 @@ class BlMesh(ReplicatedDatablock):
|
|||||||
|
|
||||||
bl_id = "meshes"
|
bl_id = "meshes"
|
||||||
bl_class = bpy.types.Mesh
|
bl_class = bpy.types.Mesh
|
||||||
bl_rep_class = BlMesh
|
bl_rep_class = BlMesh
|
||||||
|
|
||||||
|
@ -43,8 +43,7 @@ class BlObject(ReplicatedDatablock):
|
|||||||
if not target_modifier:
|
if not target_modifier:
|
||||||
target_modifier = target.modifiers.new(data['modifiers'][modifier]['name'],data['modifiers'][modifier]['type'])
|
target_modifier = target.modifiers.new(data['modifiers'][modifier]['name'],data['modifiers'][modifier]['type'])
|
||||||
|
|
||||||
utils.dump_anything.load(target_modifier, data['modifiers'][modifier])
|
# utils.dump_anything.load(target_modifier, data['modifiers'][modifier])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def dump(self, pointer=None):
|
def dump(self, pointer=None):
|
||||||
|
2
ui.py
2
ui.py
@ -110,8 +110,6 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
# STATE SYNCING
|
# STATE SYNCING
|
||||||
else:
|
else:
|
||||||
status = "connecting..."
|
status = "connecting..."
|
||||||
if net_settings.is_admin:
|
|
||||||
status = "init scene...({} tasks remaining)".format(operators.client.active_tasks)
|
|
||||||
row.label(text=status)
|
row.label(text=status)
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
||||||
|
28
utils.py
28
utils.py
@ -3,11 +3,13 @@ import sys
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import string
|
||||||
|
import random
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import mathutils
|
import mathutils
|
||||||
|
|
||||||
from . import draw, environment
|
from . import presence, environment
|
||||||
from .libs import dump_anything
|
from .libs import dump_anything
|
||||||
|
|
||||||
# TODO: replace hardcoded values...
|
# TODO: replace hardcoded values...
|
||||||
@ -18,6 +20,24 @@ logger = logging.getLogger(__name__)
|
|||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
# UTILITY FUNCTIONS
|
# UTILITY FUNCTIONS
|
||||||
|
def random_string_digits(stringLength=6):
|
||||||
|
"""Generate a random string of letters and digits """
|
||||||
|
lettersAndDigits = string.ascii_letters + string.digits
|
||||||
|
return ''.join(random.choice(lettersAndDigits) for i in range(stringLength))
|
||||||
|
|
||||||
|
|
||||||
|
def refresh_window():
|
||||||
|
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||||
|
|
||||||
|
def clean_scene():
|
||||||
|
for datablock in BPY_TYPES:
|
||||||
|
datablock_ref = getattr(bpy.data, BPY_TYPES[datablock])
|
||||||
|
for item in datablock_ref:
|
||||||
|
try:
|
||||||
|
datablock_ref.remove(item)
|
||||||
|
# Catch last scene remove
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def revers(d):
|
def revers(d):
|
||||||
@ -28,12 +48,6 @@ def revers(d):
|
|||||||
return l[::-1]
|
return l[::-1]
|
||||||
|
|
||||||
|
|
||||||
def refresh_window():
|
|
||||||
import bpy
|
|
||||||
|
|
||||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
|
||||||
|
|
||||||
|
|
||||||
def get_armature_edition_context(armature):
|
def get_armature_edition_context(armature):
|
||||||
|
|
||||||
override = {}
|
override = {}
|
||||||
|
Reference in New Issue
Block a user