Blender  V3.3
rna_fcurve_api.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <time.h>
12 
13 #include "BLI_utildefines.h"
14 
15 #include "RNA_define.h"
16 
17 #include "DNA_anim_types.h"
18 #include "DNA_scene_types.h"
19 
20 #include "rna_internal.h" /* own include */
21 
22 #ifdef RNA_RUNTIME
23 
24 # include <stddef.h>
25 
26 # include "BKE_fcurve.h"
27 
28 # include "BLI_math.h"
29 
30 static void rna_FCurve_convert_to_samples(FCurve *fcu, ReportList *reports, int start, int end)
31 {
32  /* XXX fcurve_store_samples uses end frame included,
33  * which is not consistent with usual behavior in Blender,
34  * nor python slices, etc. Let have public py API be consistent here at least. */
35  end--;
36  if (start > end) {
37  BKE_reportf(reports, RPT_ERROR, "Invalid frame range (%d - %d)", start, end + 1);
38  }
39  else if (fcu->fpt) {
40  BKE_report(reports, RPT_WARNING, "FCurve has already sample points");
41  }
42  else if (!fcu->bezt) {
43  BKE_report(reports, RPT_WARNING, "FCurve has no keyframes");
44  }
45  else {
48  }
49 }
50 
51 static void rna_FCurve_convert_to_keyframes(FCurve *fcu, ReportList *reports, int start, int end)
52 {
53  if (start >= end) {
54  BKE_reportf(reports, RPT_ERROR, "Invalid frame range (%d - %d)", start, end);
55  }
56  else if (fcu->bezt) {
57  BKE_report(reports, RPT_WARNING, "FCurve has already keyframes");
58  }
59  else if (!fcu->fpt) {
60  BKE_report(reports, RPT_WARNING, "FCurve has no sample points");
61  }
62  else {
63  fcurve_samples_to_keyframes(fcu, start, end);
65  }
66 }
67 
68 #else
69 
71 {
72  FunctionRNA *func;
73  PropertyRNA *parm;
74 
75  func = RNA_def_function(srna, "convert_to_samples", "rna_FCurve_convert_to_samples");
77  func, "Convert current FCurve from keyframes to sample points, if necessary");
79  parm = RNA_def_int(
80  func, "start", 0, MINAFRAME, MAXFRAME, "Start Frame", "", MINAFRAME, MAXFRAME);
82  parm = RNA_def_int(func, "end", 0, MINAFRAME, MAXFRAME, "End Frame", "", MINAFRAME, MAXFRAME);
84 
85  func = RNA_def_function(srna, "convert_to_keyframes", "rna_FCurve_convert_to_keyframes");
87  func,
88  "Convert current FCurve from sample points to keyframes (linear interpolation), "
89  "if necessary");
91  parm = RNA_def_int(
92  func, "start", 0, MINAFRAME, MAXFRAME, "Start Frame", "", MINAFRAME, MAXFRAME);
94  parm = RNA_def_int(func, "end", 0, MINAFRAME, MAXFRAME, "End Frame", "", MINAFRAME, MAXFRAME);
96 }
97 
99 {
100  /* FunctionRNA *func; */
101  /* PropertyRNA *parm; */
102 }
103 
104 #endif
void fcurve_samples_to_keyframes(struct FCurve *fcu, int start, int end)
Definition: fcurve.c:1084
void fcurve_store_samples(struct FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb)
Definition: fcurve.c:1037
float fcurve_samplingcb_evalcurve(struct FCurve *fcu, void *data, float evaltime)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
#define UNUSED(x)
#define MINAFRAME
#define MAXFRAME
@ PARM_REQUIRED
Definition: RNA_types.h:352
@ FUNC_USE_REPORTS
Definition: RNA_types.h:663
#define NC_ANIMATION
Definition: WM_types.h:338
#define NA_EDITED
Definition: WM_types.h:523
#define ND_ANIMCHAN
Definition: WM_types.h:444
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4347
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4342
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1518
void RNA_api_fcurves(StructRNA *srna)
void RNA_api_drivers(StructRNA *UNUSED(srna))
FPoint * fpt
BezTriple * bezt
void WM_main_add_notifier(unsigned int type, void *reference)