Refactor: Move curvemapping .blend read/write to blenkernel
This is necessary so that it can be accessed from `blendWrite` and `blendRead` callbacks from modifiers.
This commit is contained in:
@@ -37,6 +37,8 @@ struct Histogram;
|
||||
struct ImBuf;
|
||||
struct Scopes;
|
||||
struct rctf;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
|
||||
void BKE_curvemapping_set_defaults(
|
||||
struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy);
|
||||
@@ -100,6 +102,11 @@ void BKE_curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array
|
||||
/* non-const, these modify the curve */
|
||||
void BKE_curvemapping_premultiply(struct CurveMapping *cumap, int restore);
|
||||
|
||||
void BKE_curvemapping_blend_write(struct BlendWriter *writer, const struct CurveMapping *cumap);
|
||||
void BKE_curvemapping_curves_blend_write(struct BlendWriter *writer,
|
||||
const struct CurveMapping *cumap);
|
||||
void BKE_curvemapping_blend_read(struct BlendDataReader *reader, struct CurveMapping *cumap);
|
||||
|
||||
void BKE_histogram_update_sample_line(struct Histogram *hist,
|
||||
struct ImBuf *ibuf,
|
||||
const struct ColorManagedViewSettings *view_settings,
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include "IMB_colormanagement.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
/* ********************************* color curve ********************* */
|
||||
|
||||
/* ***************** operations on full struct ************* */
|
||||
@@ -1238,6 +1240,32 @@ void BKE_curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_curvemapping_blend_write(BlendWriter *writer, const CurveMapping *cumap)
|
||||
{
|
||||
BLO_write_struct(writer, CurveMapping, cumap);
|
||||
BKE_curvemapping_curves_blend_write(writer, cumap);
|
||||
}
|
||||
|
||||
void BKE_curvemapping_curves_blend_write(BlendWriter *writer, const CurveMapping *cumap)
|
||||
{
|
||||
for (int a = 0; a < CM_TOT; a++) {
|
||||
BLO_write_struct_array(writer, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve);
|
||||
}
|
||||
}
|
||||
|
||||
/* cumap itself has been read already. */
|
||||
void BKE_curvemapping_blend_read(BlendDataReader *reader, CurveMapping *cumap)
|
||||
{
|
||||
/* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
|
||||
cumap->flag &= ~CUMA_PREMULLED;
|
||||
|
||||
for (int a = 0; a < CM_TOT; a++) {
|
||||
BLO_read_data_address(reader, &cumap->cm[a].curve);
|
||||
cumap->cm[a].table = NULL;
|
||||
cumap->cm[a].premultable = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* ***************** Histogram **************** */
|
||||
|
||||
#define INV_255 (1.f / 255.f)
|
||||
|
||||
@@ -2887,16 +2887,7 @@ static void direct_link_id_common(
|
||||
/* cuma itself has been read! */
|
||||
static void direct_link_curvemapping(BlendDataReader *reader, CurveMapping *cumap)
|
||||
{
|
||||
int a;
|
||||
|
||||
/* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
|
||||
cumap->flag &= ~CUMA_PREMULLED;
|
||||
|
||||
for (a = 0; a < CM_TOT; a++) {
|
||||
BLO_read_data_address(reader, &cumap->cm[a].curve);
|
||||
cumap->cm[a].table = NULL;
|
||||
cumap->cm[a].premultable = NULL;
|
||||
}
|
||||
BKE_curvemapping_blend_read(reader, cumap);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -155,6 +155,7 @@
|
||||
#include "BKE_blender_version.h"
|
||||
#include "BKE_bpath.h"
|
||||
#include "BKE_collection.h"
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_constraint.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_fcurve.h"
|
||||
@@ -969,16 +970,12 @@ static void write_animdata(BlendWriter *writer, AnimData *adt)
|
||||
|
||||
static void write_curvemapping_curves(BlendWriter *writer, CurveMapping *cumap)
|
||||
{
|
||||
for (int a = 0; a < CM_TOT; a++) {
|
||||
BLO_write_struct_array(writer, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve);
|
||||
}
|
||||
BKE_curvemapping_curves_blend_write(writer, cumap);
|
||||
}
|
||||
|
||||
static void write_curvemapping(BlendWriter *writer, CurveMapping *cumap)
|
||||
{
|
||||
BLO_write_struct(writer, CurveMapping, cumap);
|
||||
|
||||
write_curvemapping_curves(writer, cumap);
|
||||
BKE_curvemapping_blend_write(writer, cumap);
|
||||
}
|
||||
|
||||
static void write_CurveProfile(BlendWriter *writer, CurveProfile *profile)
|
||||
|
||||
Reference in New Issue
Block a user