...
 
Commits (2)
......@@ -56,8 +56,10 @@ FutariFloor::FutariFloor() :
infinite(false),
width(1.0),
height(1.0),
up(0, 1, 0)
{
viscous(0.0),
xaxis(1, 0, 0),
yaxis(0, 1, 0),
zaxis(0, 0, 1) {
range = FUTARI_FLOOR_MINRANGE;
FutariFloor::_data.ptr = this;
FutariFloor::_data.futari_type = FutariModifierData::FMT_FLOOR;
......@@ -74,7 +76,7 @@ void FutariFloor::set_range(real_t r) {
#endif
}
void FutariFloor::set_infinite( bool b ) {
void FutariFloor::set_infinite(bool b) {
infinite = b;
#ifdef TOOLS_ENABLED
update_gizmo();
......@@ -85,8 +87,8 @@ bool FutariFloor::is_infinite() const {
return infinite;
}
void FutariFloor::set_width( real_t w ) {
width = abs( w );
void FutariFloor::set_width(real_t w) {
width = abs(w);
#ifdef TOOLS_ENABLED
update_gizmo();
#endif
......@@ -96,8 +98,8 @@ real_t FutariFloor::get_width() const {
return width;
}
void FutariFloor::set_height( real_t h ) {
height = abs( h );
void FutariFloor::set_height(real_t h) {
height = abs(h);
#ifdef TOOLS_ENABLED
update_gizmo();
#endif
......@@ -107,6 +109,14 @@ real_t FutariFloor::get_height() const {
return height;
}
void FutariFloor::set_viscous(real_t v) {
viscous = v;
}
real_t FutariFloor::get_viscous() const {
return viscous;
}
FutariModifierData* FutariFloor::data_ptr() {
return (FutariModifierData*) &(FutariFloor::_data);
}
......@@ -123,7 +133,9 @@ void FutariFloor::refresh() {
}
Vector3 p = get_global_transform().origin;
Vector3 o = get_rotation();
Vector3 o = get_transform().basis.xform(yaxis);
Vector3 vx = get_transform().basis.xform(xaxis);
Vector3 vz = get_transform().basis.xform(zaxis);
float s = strength;
if (!is_visible()) {
s *= 0;
......@@ -132,30 +144,36 @@ void FutariFloor::refresh() {
_data.changed_enabled = _data.enabled != enabled;
_data.changed_position = _data.position != p;
_data.changed_orientation = _data.orientation != o;
_data.changed_xaxis = _data.xaxis != vx;
_data.changed_zaxis = _data.zaxis != vz;
_data.changed_strength = _data.strength != s;
_data.changed_strength_decay =
_data.strength_decay != strength_decay_texture ||
_data.strength_decay.is_valid() != strength_decay_texture.is_valid();
_data.changed_lifetime =
_data.lifetime != lifetime_texture ||
_data.changed_lifetime =
_data.lifetime != lifetime_texture ||
_data.lifetime.is_valid() != lifetime_texture.is_valid();
_data.changed_infinite = _data.infinite != infinite;
_data.changed_width = _data.width != width;
_data.changed_height = _data.height != height;
_data.changed_viscous = _data.viscous != viscous;
_data.changed_range = _data.range != range;
_data.changed_velocity_mult = _data.velocity_mult != velocity_mult;
_data.changed_position_mult = _data.position_mult != position_mult;
_data.changed =
_data.changed =
_data.changed_enabled ||
_data.changed_position ||
_data.changed_orientation ||
_data.changed_xaxis ||
_data.changed_zaxis ||
_data.changed_strength ||
_data.changed_strength_decay ||
_data.changed_lifetime ||
_data.changed_infinite ||
_data.changed_width ||
_data.changed_height ||
_data.changed_viscous ||
_data.changed_range ||
_data.changed_velocity_mult ||
_data.changed_position_mult;
......@@ -164,12 +182,15 @@ void FutariFloor::refresh() {
_data.enabled = enabled;
_data.position = p;
_data.orientation = o;
_data.xaxis = vx;
_data.zaxis = vz;
_data.strength = s;
_data.strength_decay = strength_decay_texture;
_data.lifetime = lifetime_texture;
_data.infinite = infinite;
_data.width = width;
_data.height = height;
_data.viscous = viscous;
_data.range = range;
_data.velocity_mult = velocity_mult;
_data.position_mult = position_mult;
......@@ -181,18 +202,22 @@ void FutariFloor::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_infinite", "infinit"), &FutariFloor::set_infinite);
ClassDB::bind_method(D_METHOD("is_infinite"), &FutariFloor::is_infinite);
ClassDB::bind_method(D_METHOD("set_width", "width"), &FutariFloor::set_width);
ClassDB::bind_method(D_METHOD("get_width"), &FutariFloor::get_width);
ClassDB::bind_method(D_METHOD("set_height", "height"), &FutariFloor::set_height);
ClassDB::bind_method(D_METHOD("get_height"), &FutariFloor::get_height);
ADD_GROUP("Attractor", "attractor_");
ClassDB::bind_method(D_METHOD("set_viscous", "viscous"), &FutariFloor::set_viscous);
ClassDB::bind_method(D_METHOD("get_viscous"), &FutariFloor::get_viscous);
ADD_GROUP("Floor", "floor_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "get_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "infinite"), "set_infinite", "is_infinite");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width", PROPERTY_HINT_RANGE, "0,100,or_greater"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0,100,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "viscous", PROPERTY_HINT_RANGE, "0,1,0.0001,or_greater"), "set_viscous", "get_viscous");
String prop = String::num_real(FUTARI_FLOOR_MINRANGE) + ",100,0.01,or_greater";
ADD_PROPERTY(PropertyInfo(Variant::REAL, "range", PROPERTY_HINT_RANGE, prop), "set_range", "get_range");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "strength", PROPERTY_HINT_RANGE, "-500,500,or_greater,or_lesser"), "set_strength", "get_strength");
......
......@@ -63,10 +63,16 @@ public:
bool infinite;
real_t width;
real_t height;
Vector3 xaxis;
Vector3 zaxis;
real_t viscous;
bool changed_infinite;
bool changed_width;
bool changed_height;
bool changed_xaxis;
bool changed_zaxis;
bool changed_viscous;
FutariFloorData( ) :
infinite(false),
......@@ -74,7 +80,10 @@ public:
height(1.0),
changed_infinite( false ),
changed_width( false ),
changed_height( false )
changed_height( false ),
changed_xaxis( false ),
changed_zaxis( false ),
changed_viscous( false )
{
range = FUTARI_FLOOR_MINRANGE;
}
......@@ -85,6 +94,9 @@ public:
changed_infinite = false;
changed_width = false;
changed_height = false;
changed_xaxis = false;
changed_zaxis = false;
changed_viscous = false;
}
......@@ -94,9 +106,15 @@ public:
infinite = src.infinite;
width = src.width;
height = src.height;
xaxis = src.xaxis;
zaxis = src.zaxis;
viscous = src.viscous;
changed_infinite = src.changed_infinite;
changed_width = src.changed_width;
changed_height = src.changed_height;
changed_xaxis = src.changed_xaxis;
changed_zaxis = src.changed_zaxis;
changed_viscous = src.changed_viscous;
}
......@@ -119,6 +137,9 @@ public:
void set_height( real_t h );
real_t get_height() const;
void set_viscous( real_t h );
real_t get_viscous() const;
FutariModifierData* data_ptr( );
......@@ -133,8 +154,11 @@ protected:
bool infinite;
real_t width;
real_t height;
real_t viscous;
Vector3 up;
Vector3 xaxis;
Vector3 yaxis;
Vector3 zaxis;
private:
......
......@@ -50,10 +50,9 @@ enabled(FUTARI_MODIFIER_ENABLED),
range(10),
strength(1),
velocity_mult(1),
position_mult(1) {
position_mult(1),
futari_layers(1) {
_data.ptr = this;
}
FutariModifier::~FutariModifier() {
......@@ -61,7 +60,7 @@ FutariModifier::~FutariModifier() {
void FutariModifier::set_enabled(bool b) {
#ifdef TOOLS_ENABLED
if ( enabled != b ) {
if (enabled != b) {
update_gizmo();
}
#endif
......@@ -111,9 +110,9 @@ Ref<GradientTexture> FutariModifier::get_lifetime_texture() const {
}
void FutariModifier::set_velocity_mult(real_t r) {
if ( r < 0 ) {
if (r < 0) {
r = 0;
} else if ( r > 1 ) {
} else if (r > 1) {
r = 1;
}
velocity_mult = r;
......@@ -124,9 +123,9 @@ real_t FutariModifier::get_velocity_mult() const {
}
void FutariModifier::set_position_mult(real_t r) {
if ( r < 0 ) {
if (r < 0) {
r = 0;
} else if ( r > 1 ) {
} else if (r > 1) {
r = 1;
}
position_mult = r;
......@@ -211,8 +210,36 @@ void FutariModifier::_notification(int p_notification) {
};
void FutariModifier::set_futari_layer(uint32_t p_mask) {
futari_layers = p_mask;
}
uint32_t FutariModifier::get_futari_layer() const {
return futari_layers;
}
void FutariModifier::set_futari_layer_bit(int p_layer, bool p_enable) {
ERR_FAIL_INDEX(p_layer, 32);
if (p_enable) {
set_futari_layer(futari_layers | (1 << p_layer));
} else {
set_futari_layer(futari_layers & (~(1 << p_layer)));
}
}
bool FutariModifier::get_futari_layer_bit(int p_layer) const {
ERR_FAIL_INDEX_V(p_layer, 32, false);
return (futari_layers & (1 << p_layer));
}
void FutariModifier::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_futari_layer", "futari_mask"), &FutariModifier::set_futari_layer);
ClassDB::bind_method(D_METHOD("get_futari_layer"), &FutariModifier::get_futari_layer);
ClassDB::bind_method(D_METHOD("set_futari_layer_bit", "futari_layer", "enabled"), &FutariModifier::set_futari_layer_bit);
ClassDB::bind_method(D_METHOD("get_futari_layer_bit", "futari_layer"), &FutariModifier::get_futari_layer_bit);
ADD_PROPERTY(PropertyInfo(Variant::INT, "futari_layers", PROPERTY_HINT_LAYERS_3D_RENDER), "set_futari_layer", "get_futari_layer");
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &FutariModifier::set_enabled);
ClassDB::bind_method(D_METHOD("get_enabled"), &FutariModifier::get_enabled);
......@@ -230,8 +257,8 @@ void FutariModifier::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_velocity_mult", "velocity_mult"), &FutariModifier::set_velocity_mult);
ClassDB::bind_method(D_METHOD("get_velocity_mult"), &FutariModifier::get_velocity_mult);
ClassDB::bind_method(D_METHOD("set_position_mult", "position_mult"), &FutariModifier::set_position_mult);
ClassDB::bind_method(D_METHOD("get_position_mult"), &FutariModifier::get_position_mult);
}
\ No newline at end of file
......@@ -86,7 +86,7 @@ public:
int futari_type;
bool enabled;
Vector3 position;
Vector3 orientation;
real_t strength;
......@@ -109,27 +109,27 @@ public:
bool changed_velocity_mult;
bool changed_position_mult;
FutariModifierData( ) :
ptr( 0 ), futari_type( FMT_NONE ),
enabled( FUTARI_MODIFIER_ENABLED ),
strength( 0 ),
range( 0 ),
velocity_mult( 0 ),
position_mult( 0 ),
changed( false ),
changed_enabled( false ),
changed_position( false ),
changed_orientation( false ),
changed_strength( false ),
changed_strength_decay( false ),
changed_lifetime( false ),
changed_range( false ),
changed_velocity_mult( false ),
changed_position_mult( false ) {
FutariModifierData() :
ptr(0), futari_type(FMT_NONE),
enabled(FUTARI_MODIFIER_ENABLED),
strength(0),
range(0),
velocity_mult(0),
position_mult(0),
changed(false),
changed_enabled(false),
changed_position(false),
changed_orientation(false),
changed_strength(false),
changed_strength_decay(false),
changed_lifetime(false),
changed_range(false),
changed_velocity_mult(false),
changed_position_mult(false) {
}
void reset( ) {
void reset() {
changed = false;
changed_enabled = false;
......@@ -144,7 +144,7 @@ public:
}
void operator=( const FutariModifierData& src ) {
void operator=(const FutariModifierData& src) {
ptr = src.ptr;
futari_type = src.futari_type;
......@@ -166,7 +166,7 @@ public:
changed_strength_decay = src.changed_strength_decay;
changed_lifetime = src.changed_lifetime;
changed_range = src.changed_range;
changed_velocity_mult = src.changed_velocity_mult;
changed_position_mult = src.changed_position_mult;
......@@ -178,46 +178,52 @@ public:
* Mother classes of FutariWind, FutariAttractor & FutariVortex
*/
class FutariModifier : public Spatial {
GDCLASS( FutariModifier, Spatial )
GDCLASS(FutariModifier, Spatial)
public:
FutariModifier( );
virtual ~FutariModifier( );
FutariModifier();
virtual ~FutariModifier();
void set_enabled(bool b);
bool get_enabled() const;
void set_enabled( bool b );
bool get_enabled( ) const;
void set_range(real_t r);
real_t get_range() const;
void set_range( real_t r );
real_t get_range( ) const;
void set_strength(real_t r);
real_t get_strength() const;
void set_strength( real_t r );
real_t get_strength( ) const;
void set_strength_decay_texture(const Ref<GradientTexture> &tex);
Ref<GradientTexture> get_strength_decay_texture() const;
void set_strength_decay_texture( const Ref<GradientTexture> &tex );
Ref<GradientTexture> get_strength_decay_texture( ) const;
void set_lifetime_texture(const Ref<GradientTexture> &tex);
Ref<GradientTexture> get_lifetime_texture() const;
void set_lifetime_texture( const Ref<GradientTexture> &tex );
Ref<GradientTexture> get_lifetime_texture( ) const;
void set_velocity_mult(real_t r);
real_t get_velocity_mult() const;
void set_velocity_mult( real_t r );
real_t get_velocity_mult( ) const;
void set_position_mult(real_t r);
real_t get_position_mult() const;
void set_position_mult( real_t r );
real_t get_position_mult( ) const;
virtual FutariModifierData* data_ptr() = 0;
virtual FutariModifierData* data_ptr( ) = 0;
void set_futari_layer(uint32_t p_mask);
uint32_t get_futari_layer() const;
void set_futari_layer_bit(int p_layer, bool p_enable);
bool get_futari_layer_bit(int p_layer) const;
protected:
static void _bind_methods( );
void _notification( int p_notification );
static void _bind_methods();
void _notification(int p_notification);
virtual void refresh( ) = 0;
virtual void refresh() = 0;
FutariModifierData _data;
bool enabled;
real_t range;
real_t strength;
......@@ -227,6 +233,8 @@ protected:
Ref<GradientTexture> strength_decay_texture;
Ref<GradientTexture> lifetime_texture;
uint32_t futari_layers;
};
#endif /* FUTARI_MODIFIER_H */
......
This diff is collapsed.
......@@ -143,6 +143,12 @@ public:
AABB capture_aabb( ) const;
void set_futari_layer(uint32_t p_mask);
uint32_t get_futari_layer() const;
void set_futari_layer_bit(int p_layer, bool p_enable);
bool get_futari_layer_bit(int p_layer) const;
protected:
static void _bind_methods( );
......@@ -158,6 +164,8 @@ protected:
bool _procmat_refresh;
uint32_t futari_layers;
private:
RID particles;
......