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

@ -25,22 +25,22 @@ 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 |
| gpencil | :white_check_mark: | |
| image | :exclamation: | Not stable yet |
| mesh | :white_check_mark: | |
| material | :white_check_mark: | |
| metaball | :white_check_mark: | |
| object | :white_check_mark: | |
| scene | :white_check_mark: | |
| world | :white_check_mark: | |
| lightprobes | :white_check_mark: | |
| Name | Status | Comment |
| ----------- | :----------------: | :--------------------------------: |
| action | :exclamation: | Not stable |
| armature | :exclamation: | Not stable |
| camera | :white_check_mark: | |
| collection | :white_check_mark: | |
| curve | :white_check_mark: | Nurbs surface don't load correctly |
| gpencil | :white_check_mark: | |
| image | :exclamation: | Not stable yet |
| mesh | :white_check_mark: | |
| material | :white_check_mark: | |
| metaball | :white_check_mark: | |
| object | :white_check_mark: | |
| scene | :white_check_mark: | |
| world | :white_check_mark: | |
| lightprobes | :white_check_mark: | |
### Performance issues

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,51 +16,58 @@ 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
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(
new_spline.bezier_points[bezier_point_index], data['splines'][spline]["bezier_points"][bezier_point_index])
for point_index in data['splines'][spline]["points"]:
new_spline.points.add(1)
utils.dump_anything.load(
new_spline.points[point_index], data['splines'][spline]["points"][point_index])
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)
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"]:
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
def is_valid(self):
return bpy.data.curves.get(self.data['name'])
return bpy.data.curves.get(self.data['name'])