summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/audio/audio_stream_player.cpp30
-rw-r--r--scene/audio/audio_stream_player.h1
-rw-r--r--scene/resources/bit_map.cpp40
-rw-r--r--scene/resources/bit_map.h4
-rw-r--r--scene/resources/resource_format_text.cpp11
-rw-r--r--scene/resources/resource_format_text.h3
6 files changed, 38 insertions, 51 deletions
diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp
index 144e58d8b9..2def9fe8fc 100644
--- a/scene/audio/audio_stream_player.cpp
+++ b/scene/audio/audio_stream_player.cpp
@@ -32,8 +32,7 @@
#include "core/engine.h"
-
-void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames,int p_amount) {
+void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) {
int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus);
@@ -66,10 +65,8 @@ void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames,int p_amount) {
}
}
-
void AudioStreamPlayer::_mix_internal(bool p_fadeout) {
-
//get data
AudioFrame *buffer = mix_buffer.ptrw();
int buffer_size = mix_buffer.size();
@@ -94,15 +91,14 @@ void AudioStreamPlayer::_mix_internal(bool p_fadeout) {
//set volume for next mix
mix_volume_db = target_volume;
- _mix_to_bus(buffer,buffer_size);
-
+ _mix_to_bus(buffer, buffer_size);
}
void AudioStreamPlayer::_mix_audio() {
if (use_fadeout) {
- _mix_to_bus(fadeout_buffer.ptr(),fadeout_buffer.size());
- use_fadeout=false;
+ _mix_to_bus(fadeout_buffer.ptr(), fadeout_buffer.size());
+ use_fadeout = false;
}
if (!stream_playback.is_valid() || !active ||
@@ -121,7 +117,7 @@ void AudioStreamPlayer::_mix_audio() {
if (setstop) {
_mix_internal(true);
stream_playback->stop();
- setstop=false;
+ setstop = false;
}
if (setseek >= 0.0 && !stop_has_priority) {
@@ -154,7 +150,7 @@ void AudioStreamPlayer::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
if (!active || (setseek < 0 && !stream_playback->is_playing())) {
- active = false;
+ active = false;
set_process_internal(false);
emit_signal("finished");
}
@@ -200,7 +196,7 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
vol += vol_inc;
}
- use_fadeout=true;
+ use_fadeout = true;
}
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
@@ -252,7 +248,7 @@ void AudioStreamPlayer::play(float p_from_pos) {
if (stream_playback.is_valid()) {
//mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks
setseek = p_from_pos;
- stop_has_priority=false;
+ stop_has_priority = false;
active = true;
set_process_internal(true);
}
@@ -268,8 +264,8 @@ void AudioStreamPlayer::seek(float p_seconds) {
void AudioStreamPlayer::stop() {
if (stream_playback.is_valid() && active) {
- setstop=true;
- stop_has_priority=true;
+ setstop = true;
+ stop_has_priority = true;
}
}
@@ -357,7 +353,7 @@ void AudioStreamPlayer::_validate_property(PropertyInfo &property) const {
if (property.name == "bus") {
String options;
- for (int i = 0; i <AudioServer::get_singleton()->get_bus_count(); i++) {
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (i > 0)
options += ",";
String name = AudioServer::get_singleton()->get_bus_name(i);
@@ -442,8 +438,8 @@ AudioStreamPlayer::AudioStreamPlayer() {
stream_paused_fade = false;
mix_target = MIX_TARGET_STEREO;
fadeout_buffer.resize(512);
- setstop=false;
- use_fadeout=false;
+ setstop = false;
+ use_fadeout = false;
AudioServer::get_singleton()->connect("bus_layout_changed", this, "_bus_layout_changed");
}
diff --git a/scene/audio/audio_stream_player.h b/scene/audio/audio_stream_player.h
index 0b782b67e7..7987bd7e7d 100644
--- a/scene/audio/audio_stream_player.h
+++ b/scene/audio/audio_stream_player.h
@@ -112,7 +112,6 @@ public:
Ref<AudioStreamPlayback> get_stream_playback();
-
AudioStreamPlayer();
~AudioStreamPlayer();
};
diff --git a/scene/resources/bit_map.cpp b/scene/resources/bit_map.cpp
index a9d85be0dc..e4a64a1de1 100644
--- a/scene/resources/bit_map.cpp
+++ b/scene/resources/bit_map.cpp
@@ -595,16 +595,16 @@ Array BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) con
return result_array;
}
-void BitMap::resize(const Size2& p_new_size) {
+void BitMap::resize(const Size2 &p_new_size) {
Ref<BitMap> new_bitmap;
new_bitmap.instance();
new_bitmap->create(p_new_size);
- int lw = MIN(width,p_new_size.width);
- int lh = MIN(height,p_new_size.height);
- for(int x=0;x<lw;x++) {
- for(int y=0;y<lh;y++) {
- new_bitmap->set_bit(Vector2(x,y),get_bit(Vector2(x,y)));
+ int lw = MIN(width, p_new_size.width);
+ int lh = MIN(height, p_new_size.height);
+ for (int x = 0; x < lw; x++) {
+ for (int y = 0; y < lh; y++) {
+ new_bitmap->set_bit(Vector2(x, y), get_bit(Vector2(x, y)));
}
}
@@ -617,11 +617,11 @@ Ref<Image> BitMap::convert_to_image() const {
Ref<Image> image;
image.instance();
- image->create(width,height,false,Image::FORMAT_L8);
+ image->create(width, height, false, Image::FORMAT_L8);
image->lock();
- for(int i=0;i<width;i++) {
- for(int j=0;j<height;j++) {
- image->set_pixel( i,j,get_bit(Point2(i,j)) ? Color(1,1,1) : Color(0,0,0));
+ for (int i = 0; i < width; i++) {
+ for (int j = 0; j < height; j++) {
+ image->set_pixel(i, j, get_bit(Point2(i, j)) ? Color(1, 1, 1) : Color(0, 0, 0));
}
}
@@ -629,30 +629,28 @@ Ref<Image> BitMap::convert_to_image() const {
return image;
}
-void BitMap::blit(const Vector2& p_pos,const Ref<BitMap>& p_bitmap) {
+void BitMap::blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap) {
int x = p_pos.x;
int y = p_pos.y;
int w = p_bitmap->get_size().width;
int h = p_bitmap->get_size().height;
- for(int i=0;i<w;i++) {
- for (int j=0;j<h;j++) {
- int px = x+i;
- int py = y+j;
- if (px<0 || px>=width)
+ for (int i = 0; i < w; i++) {
+ for (int j = 0; j < h; j++) {
+ int px = x + i;
+ int py = y + j;
+ if (px < 0 || px >= width)
continue;
- if (py<0 || py>=height)
+ if (py < 0 || py >= height)
continue;
- if (p_bitmap->get_bit(Vector2(i,j))) {
- set_bit(Vector2(x,y),true);
+ if (p_bitmap->get_bit(Vector2(i, j))) {
+ set_bit(Vector2(x, y), true);
}
}
}
-
}
-
void BitMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("create", "size"), &BitMap::create);
diff --git a/scene/resources/bit_map.h b/scene/resources/bit_map.h
index 6e1171b8a9..daf24affb1 100644
--- a/scene/resources/bit_map.h
+++ b/scene/resources/bit_map.h
@@ -64,11 +64,11 @@ public:
int get_true_bit_count() const;
Size2 get_size() const;
- void resize(const Size2& p_new_size);
+ void resize(const Size2 &p_new_size);
void grow_mask(int p_pixels, const Rect2 &p_rect);
- void blit(const Vector2& p_pos,const Ref<BitMap>& p_bitmap);
+ void blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap);
Ref<Image> convert_to_image() const;
Vector<Vector<Vector2> > clip_opaque_to_polygons(const Rect2 &p_rect, float p_epsilon = 2.0) const;
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index e9f90fc85f..6e7bb27e74 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -447,9 +447,8 @@ Error ResourceInteractiveLoaderText::poll() {
resource_cache.push_back(res);
#ifdef TOOLS_ENABLED
//remember ID for saving
- res->set_id_for_path(local_path,index);
+ res->set_id_for_path(local_path, index);
#endif
-
}
ExtResource er;
@@ -1545,9 +1544,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}
{
-
-
-
}
#ifdef TOOLS_ENABLED
@@ -1569,7 +1565,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}
int attempt = 1; //start from one, more readable format
- while(cached_ids_found.has(attempt)) {
+ while (cached_ids_found.has(attempt)) {
attempt++;
}
@@ -1577,7 +1573,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
E->get() = attempt;
//update also in resource
Ref<Resource> res = E->key();
- res->set_id_for_path(local_path,attempt);
+ res->set_id_for_path(local_path, attempt);
}
#else
//make sure to start from one, as it makes format more readable
@@ -1598,7 +1594,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
sorted_er.sort();
-
for (int i = 0; i < sorted_er.size(); i++) {
String p = sorted_er[i].resource->get_path();
diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h
index ab6f94986c..06c841229b 100644
--- a/scene/resources/resource_format_text.h
+++ b/scene/resources/resource_format_text.h
@@ -172,10 +172,9 @@ class ResourceFormatSaverTextInstance {
struct ResourceSort {
RES resource;
int index;
- bool operator<(const ResourceSort& p_right) const {
+ bool operator<(const ResourceSort &p_right) const {
return index < p_right.index;
}
-
};
void _find_resources(const Variant &p_variant, bool p_main = false);