The goal is to solve confusion of the "All rights reserved" for licensing
code under an open-source license.
The phrase "All rights reserved" comes from a historical convention that
required this phrase for the copyright protection to apply. This convention
is no longer relevant.
However, even though the phrase has no meaning in establishing the copyright
it has not lost meaning in terms of licensing.
This change makes it so code under the Blender Foundation copyright does
not use "all rights reserved". This is also how the GPL license itself
states how to apply it to the source code:
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software ...
This change does not change copyright notice in cases when the copyright
is dual (BF and an author), or just an author of the code. It also does
mot change copyright which is inherited from NaN Holding BV as it needs
some further investigation about what is the proper way to handle it.
133 lines
3.7 KiB
C++
133 lines
3.7 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2008 Blender Foundation */
|
|
|
|
#pragma once
|
|
|
|
#include "BCSampleData.h"
|
|
#include "collada_utils.h"
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#include "BKE_armature.h"
|
|
#include "BKE_fcurve.h"
|
|
#include "BKE_material.h"
|
|
|
|
#include "ED_anim_api.h"
|
|
#include "ED_keyframes_edit.h"
|
|
#include "ED_keyframing.h"
|
|
|
|
typedef float(TangentPoint)[2];
|
|
|
|
typedef std::set<float> BCFrameSet;
|
|
typedef std::vector<float> BCFrames;
|
|
typedef std::vector<float> BCValues;
|
|
typedef std::vector<float> BCTimes;
|
|
typedef std::map<int, float> BCValueMap;
|
|
|
|
typedef enum BC_animation_type {
|
|
BC_ANIMATION_TYPE_OBJECT,
|
|
BC_ANIMATION_TYPE_BONE,
|
|
BC_ANIMATION_TYPE_CAMERA,
|
|
BC_ANIMATION_TYPE_MATERIAL,
|
|
BC_ANIMATION_TYPE_LIGHT,
|
|
} BC_animation_type;
|
|
|
|
class BCCurveKey {
|
|
private:
|
|
BC_animation_type key_type;
|
|
std::string rna_path;
|
|
int curve_array_index;
|
|
int curve_subindex; /* only needed for materials */
|
|
|
|
public:
|
|
BCCurveKey();
|
|
BCCurveKey(const BC_animation_type type,
|
|
const std::string path,
|
|
int array_index,
|
|
int subindex = -1);
|
|
void operator=(const BCCurveKey &other);
|
|
std::string get_full_path() const;
|
|
std::string get_path() const;
|
|
int get_array_index() const;
|
|
int get_subindex() const;
|
|
void set_object_type(BC_animation_type object_type);
|
|
BC_animation_type get_animation_type() const;
|
|
bool operator<(const BCCurveKey &other) const;
|
|
};
|
|
|
|
class BCBezTriple {
|
|
public:
|
|
BezTriple &bezt;
|
|
|
|
BCBezTriple(BezTriple &bezt);
|
|
float get_frame() const;
|
|
float get_time(Scene *scene) const;
|
|
float get_value() const;
|
|
float get_angle() const;
|
|
void get_in_tangent(Scene *scene, float point[2], bool as_angle) const;
|
|
void get_out_tangent(Scene *scene, float point[2], bool as_angle) const;
|
|
void get_tangent(Scene *scene, float point[2], bool as_angle, int index) const;
|
|
};
|
|
|
|
class BCAnimationCurve {
|
|
private:
|
|
BCCurveKey curve_key;
|
|
float min = 0;
|
|
float max = 0;
|
|
|
|
bool curve_is_local_copy = false;
|
|
FCurve *fcurve;
|
|
PointerRNA id_ptr;
|
|
void init_pointer_rna(Object *ob);
|
|
void delete_fcurve(FCurve *fcu);
|
|
FCurve *create_fcurve(int array_index, const char *rna_path);
|
|
void create_bezt(float frame, float output);
|
|
void update_range(float val);
|
|
void init_range(float val);
|
|
|
|
public:
|
|
BCAnimationCurve();
|
|
BCAnimationCurve(const BCAnimationCurve &other);
|
|
BCAnimationCurve(const BCCurveKey &key, Object *ob);
|
|
BCAnimationCurve(BCCurveKey key, Object *ob, FCurve *fcu);
|
|
~BCAnimationCurve();
|
|
|
|
bool is_of_animation_type(BC_animation_type type) const;
|
|
int get_interpolation_type(float sample_frame) const;
|
|
bool is_animated();
|
|
bool is_transform_curve() const;
|
|
bool is_rotation_curve() const;
|
|
bool is_keyframe(int frame);
|
|
void adjust_range(int frame);
|
|
|
|
std::string get_animation_name(Object *ob) const; /* XXX: this is COLLADA specific. */
|
|
std::string get_channel_target() const;
|
|
std::string get_channel_type() const;
|
|
std::string get_channel_posebone() const; /* returns "" if channel is not a bone channel */
|
|
|
|
int get_channel_index() const;
|
|
int get_subindex() const;
|
|
std::string get_rna_path() const;
|
|
FCurve *get_fcurve() const;
|
|
int sample_count() const;
|
|
|
|
float get_value(float frame);
|
|
void get_values(BCValues &values) const;
|
|
void get_value_map(BCValueMap &value_map);
|
|
|
|
void get_frames(BCFrames &frames) const;
|
|
|
|
/* Curve edit functions create a copy of the underlying #FCurve. */
|
|
FCurve *get_edit_fcurve();
|
|
bool add_value_from_rna(int frame);
|
|
bool add_value_from_matrix(const BCSample &sample, int frame);
|
|
void add_value(float val, int frame);
|
|
void clean_handles();
|
|
|
|
/* experimental stuff */
|
|
int closest_index_above(float sample_frame, int start_at) const;
|
|
int closest_index_below(float sample_frame) const;
|
|
};
|
|
|
|
typedef std::map<BCCurveKey, BCAnimationCurve *> BCAnimationCurveMap;
|