fix: error in utils
feat: mesh
This commit is contained in:
parent
91241185ea
commit
07f9881f0f
36
__init__.py
36
__init__.py
@ -9,20 +9,19 @@ bl_info = {
|
||||
}
|
||||
|
||||
|
||||
import addon_utils
|
||||
import logging
|
||||
import random
|
||||
import sys
|
||||
import os
|
||||
import bpy
|
||||
from . import environment, utils
|
||||
from . import environment
|
||||
from . import utils
|
||||
|
||||
|
||||
DEPENDENCIES = {
|
||||
"zmq",
|
||||
"umsgpack",
|
||||
"yaml",
|
||||
"esper"
|
||||
"yaml"
|
||||
}
|
||||
|
||||
|
||||
@ -31,24 +30,24 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
# UTILITY FUNCTIONS
|
||||
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:
|
||||
client_keys = cli.list()
|
||||
for k in client_keys:
|
||||
if 'Client' in k[0]:
|
||||
name = k[1]
|
||||
# if cli:
|
||||
# client_keys = cli.list()
|
||||
# for k in client_keys:
|
||||
# if 'Client' in k[0]:
|
||||
# name = k[1]
|
||||
|
||||
if name == username:
|
||||
name += " (self)"
|
||||
# if name == username:
|
||||
# name += " (self)"
|
||||
|
||||
items.append((name, name, ""))
|
||||
# items.append((name, name, ""))
|
||||
|
||||
return items
|
||||
return [("Common", "Common", "")]
|
||||
|
||||
|
||||
def randomColor():
|
||||
@ -191,14 +190,13 @@ class SessionProps(bpy.types.PropertyGroup):
|
||||
|
||||
classes = (
|
||||
ReplicatedDatablock,
|
||||
SessionProps
|
||||
SessionProps,
|
||||
|
||||
)
|
||||
|
||||
libs = os.path.dirname(os.path.abspath(__file__))+"\\libs\\replication"
|
||||
|
||||
def register():
|
||||
|
||||
if libs not in sys.path:
|
||||
sys.path.append(libs)
|
||||
print(libs)
|
||||
@ -211,8 +209,6 @@ def register():
|
||||
for cls in classes:
|
||||
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(
|
||||
type=SessionProps)
|
||||
|
||||
|
@ -32,7 +32,7 @@ class BlMesh(ReplicatedDatablock):
|
||||
f = mesh_buffer.faces.new(verts)
|
||||
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"])
|
||||
|
||||
mesh_buffer.to_mesh(target)
|
||||
@ -55,7 +55,7 @@ class BlMesh(ReplicatedDatablock):
|
||||
assert(pointer)
|
||||
|
||||
data = utils.dump_datablock(pointer, 2)
|
||||
utils.dump_datablock_attibute(
|
||||
utils.dump_datablock_attibutes(
|
||||
pointer, ['name', 'polygons', 'edges', 'vertices', 'id'], 6, data)
|
||||
|
||||
# Fix material index
|
||||
@ -69,5 +69,5 @@ class BlMesh(ReplicatedDatablock):
|
||||
|
||||
bl_id = "meshes"
|
||||
bl_class = bpy.types.Mesh
|
||||
bl_rep_class = BlMesh
|
||||
bl_rep_class = BlMesh
|
||||
|
||||
|
@ -43,8 +43,7 @@ class BlObject(ReplicatedDatablock):
|
||||
if not target_modifier:
|
||||
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):
|
||||
|
2
ui.py
2
ui.py
@ -110,8 +110,6 @@ class SESSION_PT_settings(bpy.types.Panel):
|
||||
# STATE SYNCING
|
||||
else:
|
||||
status = "connecting..."
|
||||
if net_settings.is_admin:
|
||||
status = "init scene...({} tasks remaining)".format(operators.client.active_tasks)
|
||||
row.label(text=status)
|
||||
row = layout.row()
|
||||
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
||||
|
28
utils.py
28
utils.py
@ -3,11 +3,13 @@ import sys
|
||||
from uuid import uuid4
|
||||
import json
|
||||
import os
|
||||
import string
|
||||
import random
|
||||
|
||||
import bpy
|
||||
import mathutils
|
||||
|
||||
from . import draw, environment
|
||||
from . import presence, environment
|
||||
from .libs import dump_anything
|
||||
|
||||
# TODO: replace hardcoded values...
|
||||
@ -18,6 +20,24 @@ logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
# 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):
|
||||
@ -28,12 +48,6 @@ def revers(d):
|
||||
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):
|
||||
|
||||
override = {}
|
||||
|
Loading…
Reference in New Issue
Block a user