diff --git a/demos/3d/navmesh/engine.cfg b/demos/3d/navmesh/engine.cfg new file mode 100644 index 00000000000..30af6ce5a5c --- /dev/null +++ b/demos/3d/navmesh/engine.cfg @@ -0,0 +1,9 @@ +[application] + +name="Navmesh Demo" +main_scene="res://navmesh.scn" +icon="res://icon.png" + +[rasterizer] + +shadow_filter=3 diff --git a/demos/3d/navmesh/navmesh.gd b/demos/3d/navmesh/navmesh.gd new file mode 100644 index 00000000000..a81a5e90d6b --- /dev/null +++ b/demos/3d/navmesh/navmesh.gd @@ -0,0 +1,110 @@ + +extends Navigation + +# member variables here, example: +# var a=2 +# var b="textvar" + +const SPEED=4.0 + +var camrot=0.0 + +var begin=Vector3() +var end=Vector3() +var m = FixedMaterial.new() + +var path=[] + +func _process(delta): + + + if (path.size()>1): + + var to_walk = delta*SPEED + var to_watch = Vector3(0,1,0) + while(to_walk>0 and path.size()>=2): + var pfrom = path[path.size()-1] + var pto = path[path.size()-2] + to_watch = (pto - pfrom).normalized() + var d = pfrom.distance_to(pto) + if (d<=to_walk): + path.remove(path.size()-1) + to_walk-=d + else: + path[path.size()-1] = pfrom.linear_interpolate(pto,to_walk/d) + to_walk=0 + + var atpos = path[path.size()-1] + var atdir = to_watch + atdir.y=0 + + var t = Transform() + t.origin=atpos + t=t.looking_at(atpos+atdir,Vector3(0,1,0)) + get_node("robot_base").set_transform(t) + + if (path.size()<2): + path=[] + set_process(false) + + else: + set_process(false) + +var draw_path=false + +func _update_path(): + + var p = get_simple_path(begin,end,true) + path=Array(p) # Vector3array to complex to use, convert to regular array + path.invert() + set_process(true) + + if (draw_path): + var im = get_node("draw") + im.set_material_override(m) + im.clear() + im.begin(Mesh.PRIMITIVE_POINTS,null) + im.add_vertex(begin) + im.add_vertex(end) + im.end() + im.begin(Mesh.PRIMITIVE_LINE_STRIP,null) + for x in p: + im.add_vertex(x) + im.end() + +func _input(ev): + + if (ev.type==InputEvent.MOUSE_BUTTON and ev.button_index==BUTTON_LEFT and ev.pressed): + + var from = get_node("cambase/Camera").project_position(ev.pos) + var to = from+get_node("cambase/Camera").project_ray_normal(ev.pos)*100 + var p = get_closest_point_to_segment(from,to) + + begin=get_closest_point(get_node("robot_base").get_translation()) + end=p + + _update_path() + + if (ev.type==InputEvent.MOUSE_MOTION): + if (ev.button_mask&BUTTON_MASK_MIDDLE): + + camrot+=ev.relative_x*0.005 + get_node("cambase").set_rotation(Vector3(0,camrot,0)) + print("camrot ", camrot) + + + +func _ready(): + # Initalization here + set_process_input(true) + m.set_line_width(3) + m.set_point_size(3) + m.set_fixed_flag(FixedMaterial.FLAG_USE_POINT_SIZE,true) + m.set_flag(Material.FLAG_UNSHADED,true) + #begin = get_closest_point(get_node("start").get_translation()) + #end = get_closest_point(get_node("end").get_translation()) + #call_deferred("_update_path") + + pass + + diff --git a/demos/3d/navmesh/navmesh.scn b/demos/3d/navmesh/navmesh.scn new file mode 100644 index 00000000000..73df340b1ec Binary files /dev/null and b/demos/3d/navmesh/navmesh.scn differ diff --git a/demos/3d/navmesh/particle.png b/demos/3d/navmesh/particle.png new file mode 100644 index 00000000000..18851c8c9de Binary files /dev/null and b/demos/3d/navmesh/particle.png differ diff --git a/drivers/theoraplayer/SCsub b/drivers/theoraplayer/SCsub index 979ff2ed1bd..d4218debb61 100644 --- a/drivers/theoraplayer/SCsub +++ b/drivers/theoraplayer/SCsub @@ -67,10 +67,13 @@ if env["platform"] == "iphone": env_theora = env.Clone() -env_theora.Append(CPPFLAGS=["-D_YUV_C", "-D__THEORA", "-D_LIB"]) +env_theora.Append(CPPFLAGS=["-D_YUV_C", "-D_LIB", "-D__THEORA"]) if env["platform"] == "iphone": env_theora.Append(CPPFLAGS=["-D__AVFOUNDATION"]) +else: + pass + #env_theora.Append(CPPFLAGS=["-D__FFMPEG"]) if env["platform"] == "android": env_theora.Append(CPPFLAGS=["-D_ANDROID"]) diff --git a/drivers/theoraplayer/src/AVFoundation/TheoraVideoClip_AVFoundation.mm b/drivers/theoraplayer/src/AVFoundation/TheoraVideoClip_AVFoundation.mm index 72e3dfc9fa2..1b5cf0ab13b 100644 --- a/drivers/theoraplayer/src/AVFoundation/TheoraVideoClip_AVFoundation.mm +++ b/drivers/theoraplayer/src/AVFoundation/TheoraVideoClip_AVFoundation.mm @@ -271,6 +271,8 @@ void TheoraVideoClip_AVFoundation::load(TheoraDataSource* source) AVAssetTrack *videoTrack = [tracks objectAtIndex:0]; NSArray* audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio]; + if (audio_track >= audioTracks.count) + audio_track = 0; AVAssetTrack *audioTrack = audioTracks.count > 0 ? [audioTracks objectAtIndex:audio_track] : NULL; printf("*********** using audio track %i\n", audio_track); diff --git a/drivers/theoraplayer/video_stream_theoraplayer.cpp b/drivers/theoraplayer/video_stream_theoraplayer.cpp index 643899aaede..62dee1336a7 100644 --- a/drivers/theoraplayer/video_stream_theoraplayer.cpp +++ b/drivers/theoraplayer/video_stream_theoraplayer.cpp @@ -122,6 +122,7 @@ class AudioStreamInput : public AudioStreamResampled { int rb_power; int total_wrote; bool playing; + bool paused; public: @@ -133,6 +134,7 @@ public: AudioServer::get_singleton()->stream_set_active(stream_rid,true); AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,1); playing = true; + paused = false; }; virtual void stop() { @@ -146,8 +148,8 @@ public: virtual bool is_playing() const { return true; }; - virtual void set_paused(bool p_paused) {}; - virtual bool is_paused(bool p_paused) const { return false; }; + virtual void set_paused(bool p_paused) { paused = p_paused; }; + virtual bool is_paused(bool p_paused) const { return paused; }; virtual void set_loop(bool p_enable) {}; virtual bool has_loop() const { return false; }; @@ -209,6 +211,7 @@ public: AudioStreamInput(int p_channels, int p_freq) { playing = false; + paused = true; channels = p_channels; freq = p_freq; total_wrote = 0; @@ -285,12 +288,12 @@ void VideoStreamTheoraplayer::stop() { clip->stop(); clip->seek(0); }; + started = true; }; void VideoStreamTheoraplayer::play() { - - playing = true; - started = true; + if (clip) + playing = true; }; bool VideoStreamTheoraplayer::is_playing() const { @@ -300,7 +303,13 @@ bool VideoStreamTheoraplayer::is_playing() const { void VideoStreamTheoraplayer::set_paused(bool p_paused) { - playing = false; + paused = p_paused; + if (paused) { + clip->pause(); + } else { + if (clip && playing && !started) + clip->play(); + } }; bool VideoStreamTheoraplayer::is_paused(bool p_paused) const { @@ -355,6 +364,9 @@ int VideoStreamTheoraplayer::get_pending_frame_count() const { void VideoStreamTheoraplayer::pop_frame(Ref p_tex) { + if (!clip) + return; + TheoraVideoFrame* f = clip->getNextFrame(); if (!f) { return; @@ -374,7 +386,7 @@ void VideoStreamTheoraplayer::pop_frame(Ref p_tex) { { DVector::Write wr = data.write(); uint8_t* ptr = wr.ptr(); - memcpy(ptr, f->getBuffer(), imgsize); + copymem(ptr, f->getBuffer(), imgsize); } /* for (int i=0; igetNumReadyFrames() < 2) { @@ -499,6 +517,7 @@ VideoStreamTheoraplayer::VideoStreamTheoraplayer() { clip = NULL; started = false; playing = false; + paused = false; loop = false; audio_track=0; }; diff --git a/drivers/theoraplayer/video_stream_theoraplayer.h b/drivers/theoraplayer/video_stream_theoraplayer.h index f926dfdaf50..d43c12609fe 100644 --- a/drivers/theoraplayer/video_stream_theoraplayer.h +++ b/drivers/theoraplayer/video_stream_theoraplayer.h @@ -17,6 +17,7 @@ class VideoStreamTheoraplayer : public VideoStream { bool started; bool playing; bool loop; + bool paused; int audio_track; diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 8738185d413..7085ae6a568 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -2464,6 +2464,8 @@ void GDScriptLanguage::get_reserved_words(List *p_words) const { "assert", "yield", "static", + "float", + "int", 0}; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 19bf3249168..8eb5746948c 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1494,7 +1494,7 @@ OS::Date OS_Windows::get_date() const { OS::Time OS_Windows::get_time() const { SYSTEMTIME systemtime; - GetSystemTime(&systemtime); + GetLocalTime(&systemtime); Time time; time.hour=systemtime.wHour;