fix: curve commit error

Releated to #72
This commit is contained in:
Swann 2020-03-10 18:00:23 +01:00
parent 9df7cd4659
commit 9f59e7b6e8
No known key found for this signature in database
GPG Key ID: B880407E0F5F413E
2 changed files with 50 additions and 40 deletions

View File

@ -26,12 +26,12 @@ See the [documentation](https://multi-user.readthedocs.io/en/latest/) for detail
Currently, not all data-block are supported for replication over the wire. The following list summarizes the status for each ones.
| Name | Status | Comment |
| ----------- | :----------------: | :------------: |
| ----------- | :----------------: | :--------------------------------: |
| action | :exclamation: | Not stable |
| armature | :exclamation: | Not stable |
| camera | :white_check_mark: | |
| collection | :white_check_mark: | |
| curve | :white_check_mark: | Not tested |
| curve | :white_check_mark: | Nurbs surface don't load correctly |
| gpencil | :white_check_mark: | |
| image | :exclamation: | Not stable yet |
| mesh | :white_check_mark: | |

View File

@ -1,8 +1,11 @@
import bpy
import bpy.types as T
import mathutils
from .. import utils
from .bl_datablock import BlDatablock
from ..libs import dump_anything
class BlCurve(BlDatablock):
bl_id = "curves"
@ -13,49 +16,56 @@ class BlCurve(BlDatablock):
bl_icon = 'CURVE_DATA'
def construct(self, data):
return bpy.data.curves.new(data["name"], 'CURVE')
return bpy.data.curves.new(data["name"], data["type"])
def load(self, data, target):
utils.dump_anything.load(target, data)
def load_implementation(self, data, target):
dump_anything.load(target, data)
target.splines.clear()
# load splines
for spline in data['splines']:
new_spline = target.splines.new(data['splines'][spline]['type'])
utils.dump_anything.load(new_spline, data['splines'][spline])
dump_anything.load(new_spline, data['splines'][spline])
# Load curve geometry data
if new_spline.type == 'BEZIER':
for bezier_point_index in data['splines'][spline]["bezier_points"]:
if bezier_point_index != 0:
new_spline.bezier_points.add(1)
utils.dump_anything.load(
dump_anything.load(
new_spline.bezier_points[bezier_point_index], data['splines'][spline]["bezier_points"][bezier_point_index])
# Not really working for now...
# See https://blender.stackexchange.com/questions/7020/create-nurbs-surface-with-python
if new_spline.type == 'NURBS':
new_spline.points.add(len(data['splines'][spline]["points"])-1)
for point_index in data['splines'][spline]["points"]:
new_spline.points.add(1)
utils.dump_anything.load(
dump_anything.load(
new_spline.points[point_index], data['splines'][spline]["points"][point_index])
def dump_implementation(self, data, pointer=None):
assert(pointer)
data = utils.dump_datablock(pointer, 1)
dumper = dump_anything.Dumper()
data = dumper.dump(pointer)
data['splines'] = {}
dumper = utils.dump_anything.Dumper()
dumper.depth = 3
for index,spline in enumerate(pointer.splines):
spline_data = {}
for index, spline in enumerate(pointer.splines):
spline_data = dump_anything.dump(spline)
spline_data['points'] = dumper.dump(spline.points)
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'):
if isinstance(pointer, T.SurfaceCurve):
data['type'] = 'SURFACE'
if isinstance(pointer,'TextCurve'):
elif isinstance(pointer, T.TextCurve):
data['type'] = 'FONT'
elif isinstance(pointer, T.Curve):
data['type'] = 'CURVE'
return data