Page MenuHome

linked curves with curve modifiers arent drawn correctly
Closed, ResolvedPublic

Description

System Information
Operating system: Win 10
Graphics card: GTX 1080TI

Blender Version
Broken:
4ef09cf937f2
Worked: 2.79b

Short description of error
Whenever you have data-linked curves and both of them have curve modifiers, only the original curve will deform if you move it in object mode. Check 2,79 for correct behavior (you can have linked curves but they will deform separately). Also, if you have a modifier on a curve, blender starts to draw the original and deformed curve at the same time (which is pretty confusing).

Exact steps for others to reproduce the error
Here's a simple .blend with the issue

Event Timeline

Philipp Oeser (lichtwerk) triaged this task as Confirmed, Medium priority.

Can confirm, @Bastien Montagne (mont29): iirc you've been active with (curve) modifiers? [just reaasign if that is not for you...]

Hrrmmm… this looks like different evaluated instances of curves sharing some data somehow (either at cache level, or something else?). Wouldn’t mind some @Sergey Sharybin (sergey) advice here first, in case he has some quick insight on the issue, before I dive again into curve eval process (which will take time…).

There's also a problem with curve drawing with modifiers. For example, create a curve and add a mirror modifier to it, it's not drawn in the viewport

@Clément Foucault (fclem) I think that is drawing code issue in fact, adding a printf at start of DRW_curve_batch_cache_create_requested(), I get things like:

DRW_curve_batch_cache_create_requested: CUBezierCircle (curve_cache: 0x6110004125c8), from OBBezierCircle
DRW_curve_batch_cache_create_requested: CUBezierCircle (curve_cache: 0x6110004125c8), from OBBezierCircle.001

…so looks like drawcache is shared by different objects if they use same curve obdata? At least, that function seems to take data from ob->runtime.curve_cache and use it to fill the VBOs of cu->batch_cache, if I follow it correctly.

@Bastien Montagne (mont29) You are right. And this is wrong.
It seems that the Object Data (Curve *)ob->data (Which is what holds the batch cache) is not duplicated as it should.

This is how Mesh are handled, (Mesh *)ob->data is NEVER shared if there is a modifier stack.

After talking with @Sergey Sharybin (sergey) it seems that storing the batch cache inside the object data is not a good idea. A better idea would be to store it inside the Object_Runtime struct and do some optimisation down the road to share the object runtime on similar object (i.e.: objects with the same ob->data and no modifiers).

But doing this requires some changes inside the depsgraph for tagging the object instead of the object data (notably the operation node GEOMETRY_SELECT_UPDATE). I'll propose a patch for this soon.

@Sergey Sharybin (sergey) After trying to go into this direction it seems really to be a can of worm situation. A lot of code it based on Eval Mesh* tagging / batch free/update.

I think the short term solution would be either:

  • Port code in Curve/Surf/Text to use Curve->runtime to produce final mesh and duplicate the Curve obdata so that modifiers are applied interdependently. The first part is even optional.
  • Create an exception for Curves and use (newly created) Object_Runtime->batch_cache, then port Mesh to use it in a second time. This is the most straight forward (and follow @Sergey Sharybin (sergey) suggestion) but it's causing me problem as it needs some refactor inside the Despgraph (namely build_object_data_geometry_datablock that takes an obdata ID* as input instead of a OB).

The implication of all this makes me wonder why / what was the original design supposed to be? Having multiple ways of dealing with modified geometry seems kind of bad from my point of view.

Port code in Curve/Surf/Text to use Curve->runtime to produce final mesh and duplicate the Curve obdata so that modifiers are applied interdependently.

Not sure what that means. The conversion to mesh can only happen after tessellation point of modifier stack of curve object. If you create mesh prior that you can no longer to bevel/taper, and can not apply deformation modifiers on the control points.

it needs some refactor inside the Despgraph (namely build_object_data_geometry_datablock that takes an obdata ID* as input instead of a OB).

I am not sure why any changes to the dependency graph are needed.

To me it seems all changes are needed in BKE_displist_make_surf(), or maybe even in curve_calc_modifiers_post() to convert the nurbs list to mesh after the modifier stack has been evaluated. Effectively, do the same thing as the constructive modifiers do: convert nurbs to mesh, if the mesh is not yet created after the modifiers loop is finished.

Then the only exception is that you'd need to access Object.runtime.mesh_final as an opposite to Mesh case when you can do Object.data. This is because we can not change object type during evaluation.

Clément Foucault (fclem) raised the priority of this task from Confirmed, Medium to Confirmed, High.Apr 15 2019, 12:28 PM

This still isn't fully resolved, even though curves are now behaving correctly with mirror/array modifiers, try link copying a curve (using Alt+D) which has a curve modifier on it and you'll see what i mean. The outline is drawn correctly but the mesh data itself is not, i think it's a depsgraph thing.

@Artem (Hickz) The original file does work here and did exhibit exactly what you are describing. Can you make a screenshot and/or post a new file exhibiting the issue?

Artem (Hickz) added a comment.EditedApr 25 2019, 11:28 PM

@Clément Foucault (fclem)

You can find one file here https://developer.blender.org/T63871 (i created a new task for a new problem, this is related i think)

The file for this particular problem is:


Try moving curve2 object, you'll see what i mean about the outline (it is drawn correctly, but not the mesh data)

this problem appears when you apply the modifier to curve points (this button is switched on)

@Clément Foucault (fclem)

Should this be reopened, do you think? This problem is pretty huge i think (at least for my jewelry modeling workflow)