瀏覽代碼

-vec3 uniforms should now work, fixes #1773

Juan Linietsky 10 年之前
父節點
當前提交
a76709d240
共有 4 個文件被更改,包括 43 次插入10 次删除
  1. 36 8
      core/io/resource_loader.cpp
  2. 6 1
      demos/2d/kinematic_char/player.gd
  3. 0 0
      demos/2d/platformer/stage.xml
  4. 1 1
      scene/resources/shader_graph.cpp

+ 36 - 8
core/io/resource_loader.cpp

@@ -117,6 +117,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoader::load_interactive(const Stri
 
 RES ResourceFormatLoader::load(const String &p_path,const String& p_original_path) {
 
+	String path=p_path;
 
 	//or this must be implemented
 	Ref<ResourceInteractiveLoader> ril = load_interactive(p_path);
@@ -150,9 +151,13 @@ void ResourceFormatLoader::get_dependencies(const String& p_path,List<String> *p
 
 RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_no_cache) {
 
-	String local_path = Globals::get_singleton()->localize_path(p_path);
+	String local_path;
+	if (p_path.is_rel_path())
+		local_path="res://"+p_path;
+	else
+		local_path = Globals::get_singleton()->localize_path(p_path);
 
-	local_path=find_complete_path(p_path,p_type_hint);
+	local_path=find_complete_path(local_path,p_type_hint);
 	ERR_FAIL_COND_V(local_path=="",RES());
 
 	if (!p_no_cache && ResourceCache::has(local_path)) {
@@ -209,7 +214,11 @@ RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_n
 Ref<ResourceImportMetadata> ResourceLoader::load_import_metadata(const String &p_path) {
 
 
-	String local_path = Globals::get_singleton()->localize_path(p_path);
+	String local_path;
+	if (p_path.is_rel_path())
+		local_path="res://"+p_path;
+	else
+		local_path = Globals::get_singleton()->localize_path(p_path);
 
 	String extension=p_path.extension();
 	bool found=false;
@@ -283,9 +292,13 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
 
 
 
-	String local_path = Globals::get_singleton()->localize_path(p_path);
+	String local_path;
+	if (p_path.is_rel_path())
+		local_path="res://"+p_path;
+	else
+		local_path = Globals::get_singleton()->localize_path(p_path);
 
-	local_path=find_complete_path(p_path,p_type_hint);
+	local_path=find_complete_path(local_path,p_type_hint);
 	ERR_FAIL_COND_V(local_path=="",Ref<ResourceInteractiveLoader>());
 
 
@@ -340,7 +353,13 @@ void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_l
 
 void ResourceLoader::get_dependencies(const String& p_path,List<String> *p_dependencies) {
 
-	String local_path = Globals::get_singleton()->localize_path(p_path);
+
+	String local_path;
+	if (p_path.is_rel_path())
+		local_path="res://"+p_path;
+	else
+		local_path = Globals::get_singleton()->localize_path(p_path);
+
 	String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
 
 	String extension=remapped_path.extension();
@@ -359,7 +378,11 @@ void ResourceLoader::get_dependencies(const String& p_path,List<String> *p_depen
 
 String ResourceLoader::guess_full_filename(const String &p_path,const String& p_type) {
 
-	String local_path = Globals::get_singleton()->localize_path(p_path);
+	String local_path;
+	if (p_path.is_rel_path())
+		local_path="res://"+p_path;
+	else
+		local_path = Globals::get_singleton()->localize_path(p_path);
 
 	return find_complete_path(local_path,p_type);
 
@@ -367,7 +390,12 @@ String ResourceLoader::guess_full_filename(const String &p_path,const String& p_
 
 String ResourceLoader::get_resource_type(const String &p_path) {
 
-	String local_path = Globals::get_singleton()->localize_path(p_path);
+	String local_path;
+	if (p_path.is_rel_path())
+		local_path="res://"+p_path;
+	else
+		local_path = Globals::get_singleton()->localize_path(p_path);
+
 	String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
 	String extension=remapped_path.extension();
 

+ 6 - 1
demos/2d/kinematic_char/player.gd

@@ -23,6 +23,7 @@ const JUMP_MAX_AIRBORNE_TIME=0.2
 
 const SLIDE_STOP_VELOCITY=1.0 #one pixel per second
 const SLIDE_STOP_MIN_TRAVEL=1.0 #one pixel
+
 var velocity = Vector2()
 var on_air_time=100
 var jumping=false
@@ -94,7 +95,7 @@ func _fixed_process(delta):
 			#Since this formula will always slide the character around, 
 			#a special case must be considered to to stop it from moving 
 			#if standing on an inclined floor. Conditions are:
-			# 1) Standin on floor (on_air_time==0)
+			# 1) Standing on floor (on_air_time==0)
 			# 2) Did not move more than one pixel (get_travel().length() < SLIDE_STOP_MIN_TRAVEL)
 			# 3) Not moving horizontally (abs(velocity.x) < SLIDE_STOP_VELOCITY)
 			# 4) Collider is not moving
@@ -117,9 +118,13 @@ func _fixed_process(delta):
 		move(floor_velocity*delta)
 
 	if (jumping and velocity.y>0):
+		#if falling, no longer jumping
 		jumping=false
 		
 	if (on_air_time<JUMP_MAX_AIRBORNE_TIME and jump and not prev_jump_pressed and not jumping):	
+		# Jump must also be allowed to happen if the
+		# character left the floor a little bit ago.
+		# Makes controls more snappy.
 		velocity.y=-JUMP_SPEED	
 		jumping=true
 		

File diff suppressed because it is too large
+ 0 - 0
demos/2d/platformer/stage.xml


+ 1 - 1
scene/resources/shader_graph.cpp

@@ -2378,7 +2378,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
 
 			String name = p_node->param1;
 			Vector3 dv=p_node->param2;
-			code +="uniform float "+name+"=vec3("+rtos(dv.x)+","+rtos(dv.y)+","+rtos(dv.z)+");\n";
+			code +="uniform vec3 "+name+"=vec3("+rtos(dv.x)+","+rtos(dv.y)+","+rtos(dv.z)+");\n";
 			code += OUTNAME(p_node->id,0)+"="+name+";\n";
 		}break;
 		case NODE_RGB_INPUT: {

Some files were not shown because too many files changed in this diff