Skip to content

Commit

Permalink
Batch of Bugfixes
Browse files Browse the repository at this point in the history
-=-=-=-=-=-=-=-=-

-Fixed Export UV XForm (should work now). #923
-Fixed enforcement of limits in property editor. #919
-Fixed long-standing bug of export editings in script inheritance. #914, #859, #756
-Fixed horrible error reporting in shader language. #912
-Added kinematic collision with plane (please test well). #911
-Fixed double animation track insert when using 2D rigs. #904
-VKey updates offset parameter in sprite edition. #901
-Do not allow anymore a script to preload itself. (does not fix #899, but narrows it down)
-Avoid connection editor from overriding selected text. #897
-Fixed timer autostart. #876
-Fixed collision layers in 3D physics. #872
-Improved operators in shader #857
-Fixed ambient lighting bug #834
-Avoid editor from processing gamepad input #813
-Added not keyword #752

Please test!
  • Loading branch information
reduz committed Dec 7, 2014
1 parent f7c9a4a commit c79be97
Show file tree
Hide file tree
Showing 35 changed files with 491 additions and 115 deletions.
Binary file modified demos/3d/truck_town/crane.scn
Binary file not shown.
199 changes: 151 additions & 48 deletions doc/base/classes.xml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion drivers/gles2/rasterizer_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4648,7 +4648,8 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD
if (m->flags[VS::MATERIAL_FLAG_INVERT_FACES])
e->mirror=!e->mirror;

e->light_type=0xFF; // no lights!
//e->light_type=0xFF; // no lights!
e->light_type=3; //light type 3 is no light?
e->light=0xFFFF;

if (!shadow && !has_blend_alpha && has_alpha && m->depth_draw_mode==VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA) {
Expand Down Expand Up @@ -9122,6 +9123,7 @@ void RasterizerGLES2::init() {
use_anisotropic_filter=true;
float_linear_supported=true;
float_supported=true;
use_rgba_shadowmaps=false;

glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,&anisotropic_level);
anisotropic_level=MIN(anisotropic_level,float(GLOBAL_DEF("rasterizer/anisotropic_filter_level",4.0)));
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles2/shaders/material.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ LIGHT_SHADER_CODE
# if !defined(LIGHT_TYPE_DIRECTIONAL) && !defined(LIGHT_TYPE_OMNI) && !defined (LIGHT_TYPE_SPOT)
//none
#ifndef SHADELESS
diffuse.rgb=vec3(0.0,0.0,0.0);
diffuse.rgb=ambient_light *diffuse.rgb;
#endif

# endif
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gd_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool GDScriptLanguage::validate(const String& p_script, int &r_line_error,int &r

GDParser parser;

Error err = parser.parse(p_script,p_path.get_base_dir(),true);
Error err = parser.parse(p_script,p_path.get_base_dir(),true,p_path);
if (err) {
r_line_error=parser.get_error_line();
r_col_error=parser.get_error_column();
Expand Down
16 changes: 12 additions & 4 deletions modules/gdscript/gd_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,14 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
String path = tokenizer->get_token_constant();
if (!path.is_abs_path() && base_path!="")
path=base_path+"/"+path;
path = path.replace("///","//");
path = path.replace("///","//").simplify_path();
if (path==self_path) {

_set_error("Can't preload itself (use 'get_script()').");
return NULL;

}


Ref<Resource> res;
if (!validating) {
Expand Down Expand Up @@ -2616,8 +2623,9 @@ Error GDParser::_parse(const String& p_base_path) {
return OK;
}

Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p_base_path) {
Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p_base_path, const String &p_self_path) {

self_path=p_self_path;
GDTokenizerBuffer *tb = memnew( GDTokenizerBuffer );
tb->set_code_buffer(p_bytecode);
tokenizer=tb;
Expand All @@ -2628,9 +2636,9 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p
}


Error GDParser::parse(const String& p_code,const String& p_base_path,bool p_just_validate) {

Error GDParser::parse(const String& p_code, const String& p_base_path, bool p_just_validate, const String &p_self_path) {

self_path=p_self_path;
GDTokenizerText *tt = memnew( GDTokenizerText );
tt->set_code(p_code);

Expand Down
5 changes: 3 additions & 2 deletions modules/gdscript/gd_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ class GDParser {
List<int> tab_level;

String base_path;
String self_path;

PropertyInfo current_export;

Expand All @@ -398,8 +399,8 @@ class GDParser {
String get_error() const;
int get_error_line() const;
int get_error_column() const;
Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false);
Error parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p_base_path="");
Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false,const String& p_self_path="");
Error parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p_base_path="",const String& p_self_path="");

const Node *get_parse_tree() const;

Expand Down
164 changes: 129 additions & 35 deletions modules/gdscript/gd_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
placeholders.erase(p_placeholder);
}

/*
void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {


Expand Down Expand Up @@ -1563,7 +1564,7 @@ void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {

p_placeholder->update(plist,default_values);

}
}*/
#endif
ScriptInstance* GDScript::instance_create(Object *p_this) {

Expand All @@ -1582,7 +1583,8 @@ ScriptInstance* GDScript::instance_create(Object *p_this) {
}*/
PlaceHolderScriptInstance *si = memnew( PlaceHolderScriptInstance(GDScriptLanguage::get_singleton(),Ref<Script>(this),p_this) );
placeholders.insert(si);
_update_placeholder(si);
//_update_placeholder(si);
_update_exports();
return si;
#else
return NULL;
Expand Down Expand Up @@ -1623,70 +1625,157 @@ String GDScript::get_source_code() const {
}
void GDScript::set_source_code(const String& p_code) {

if (source==p_code)
return;
source=p_code;
#ifdef TOOLS_ENABLED
source_changed_cache=true;
//print_line("SC CHANGED "+get_path());
#endif

}

#ifdef TOOLS_ENABLED
void GDScript::_update_exports_values(Map<StringName,Variant>& values, List<PropertyInfo> &propnames) {

if (base_cache.is_valid()) {
base_cache->_update_exports_values(values,propnames);
}

for(Map<StringName,Variant>::Element *E=member_default_values_cache.front();E;E=E->next()) {
values[E->key()]=E->get();
}

for (List<PropertyInfo>::Element *E=members_cache.front();E;E=E->next()) {
propnames.push_back(E->get());
}

}
#endif

void GDScript::_update_exports(Set<PlaceHolderScriptInstance*> *p_instances) {
bool GDScript::_update_exports() {

#ifdef TOOLS_ENABLED

String basedir=path;
bool changed=false;

if (basedir=="")
basedir=get_path();
if (source_changed_cache) {
//print_line("updating source for "+get_path());
source_changed_cache=false;
changed=true;

if (basedir!="")
basedir=basedir.get_base_dir();
String basedir=path;

GDParser parser;
Error err = parser.parse(source,basedir,true);
if (err)
return; //do none
if (basedir=="")
basedir=get_path();

const GDParser::Node* root = parser.get_parse_tree();
ERR_FAIL_COND(root->type!=GDParser::Node::TYPE_CLASS);
if (basedir!="")
basedir=basedir.get_base_dir();

GDParser parser;
Error err = parser.parse(source,basedir,true,path);

if (err==OK) {

const GDParser::ClassNode *c = static_cast<const GDParser::ClassNode*>(root);
const GDParser::Node* root = parser.get_parse_tree();
ERR_FAIL_COND_V(root->type!=GDParser::Node::TYPE_CLASS,false);

if (c->extends_used && String(c->extends_file)!="") {
const GDParser::ClassNode *c = static_cast<const GDParser::ClassNode*>(root);

Ref<GDScript> bf = ResourceLoader::load(c->extends_file);
if (bf.is_valid()) {
if (base_cache.is_valid()) {
base_cache->inheriters_cache.erase(get_instance_ID());
base_cache=Ref<GDScript>();
}

bf->_update_exports(p_instances);

}
}
if (c->extends_used && String(c->extends_file)!="") {

List<PropertyInfo> plist;
String path = c->extends_file;
if (path.is_rel_path()) {

Map<StringName,Variant> default_values;
String base = get_path();
if (base=="" || base.is_rel_path()) {

for(int i=0;i<c->variables.size();i++) {
if (c->variables[i]._export.type==Variant::NIL)
continue;
ERR_PRINT(("Could not resolve relative path for parent class: "+path).utf8().get_data());
} else {
path=base.get_base_dir().plus_file(path);
}
}

Ref<GDScript> bf = ResourceLoader::load(path);

if (bf.is_valid()) {

//print_line("parent is: "+bf->get_path());
base_cache=bf;
bf->inheriters_cache.insert(get_instance_ID());

//bf->_update_exports(p_instances,true,false);

}
}

members_cache.clear();;
member_default_values_cache.clear();

for(int i=0;i<c->variables.size();i++) {
if (c->variables[i]._export.type==Variant::NIL)
continue;

members_cache.push_back(c->variables[i]._export);
//print_line("found "+c->variables[i]._export.name);
member_default_values_cache[c->variables[i].identifier]=c->variables[i].default_value;
}
}
} else {
//print_line("unchaged is "+get_path());

plist.push_back(c->variables[i]._export);
default_values[c->variables[i].identifier]=c->variables[i].default_value;
}

if (base_cache.is_valid()) {
if (base_cache->_update_exports()) {
changed = true;
}
}

if (/*changed &&*/ placeholders.size()) { //hm :(

//print_line("updating placeholders for "+get_path());

for (Set<PlaceHolderScriptInstance*>::Element *E=p_instances->front();E;E=E->next()) {
//update placeholders if any
Map<StringName,Variant> values;
List<PropertyInfo> propnames;
_update_exports_values(values,propnames);

E->get()->update(plist,default_values);
for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) {

E->get()->update(propnames,values);
}
}

return changed;

#endif
}

void GDScript::update_exports() {

#ifdef TOOLS_ENABLED

_update_exports(&placeholders);
_update_exports();

Set<ObjectID> copy=inheriters_cache; //might get modified

//print_line("update exports for "+get_path()+" ic: "+itos(copy.size()));
for(Set<ObjectID>::Element *E=copy.front();E;E=E->next()) {
Object *id=ObjectDB::get_instance(E->get());
if (!id)
continue;
GDScript *s=id->cast_to<GDScript>();
if (!s)
continue;
s->update_exports();
}

#endif
}
Expand Down Expand Up @@ -1718,7 +1807,7 @@ Error GDScript::reload() {

valid=false;
GDParser parser;
Error err = parser.parse(source,basedir);
Error err = parser.parse(source,basedir,false,path);
if (err) {
if (ScriptDebugger::get_singleton()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(),parser.get_error_line(),"Parser Error: "+parser.get_error());
Expand Down Expand Up @@ -1746,10 +1835,10 @@ Error GDScript::reload() {
}

#ifdef TOOLS_ENABLED
for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) {
/*for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) {

_update_placeholder(E->get());
}
}*/
#endif
return OK;
}
Expand Down Expand Up @@ -1892,7 +1981,7 @@ Error GDScript::load_byte_code(const String& p_path) {

valid=false;
GDParser parser;
Error err = parser.parse_bytecode(bytecode,basedir);
Error err = parser.parse_bytecode(bytecode,basedir,get_path());
if (err) {
_err_print_error("GDScript::load_byte_code",path.empty()?"built-in":(const char*)path.utf8().get_data(),parser.get_error_line(),("Parse Error: "+parser.get_error()).utf8().get_data());
ERR_FAIL_V(ERR_PARSE_ERROR);
Expand Down Expand Up @@ -1945,6 +2034,8 @@ Error GDScript::load_source_code(const String& p_path) {
}

source=s;
source_changed_cache=true;
//print_line("LSC :"+get_path());
path=p_path;
return OK;

Expand Down Expand Up @@ -1986,6 +2077,9 @@ GDScript::GDScript() {
_base=NULL;
_owner=NULL;
tool=false;
#ifdef TOOLS_ENABLED
source_changed_cache=false;
#endif

}

Expand Down
13 changes: 11 additions & 2 deletions modules/gdscript/gd_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,16 @@ friend class GDScriptLanguage;
Map<StringName,Ref<GDScript> > subclasses;

#ifdef TOOLS_ENABLED

Map<StringName,Variant> member_default_values;

List<PropertyInfo> members_cache;
Map<StringName,Variant> member_default_values_cache;
Ref<GDScript> base_cache;
Set<ObjectID> inheriters_cache;
bool source_changed_cache;
void _update_exports_values(Map<StringName,Variant>& values, List<PropertyInfo> &propnames);

#endif
Map<StringName,PropertyInfo> member_info;

Expand All @@ -265,13 +274,13 @@ friend class GDScriptLanguage;

#ifdef TOOLS_ENABLED
Set<PlaceHolderScriptInstance*> placeholders;
void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
//void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
#endif



void _update_exports(Set<PlaceHolderScriptInstance *> *p_instances);
bool _update_exports();

protected:
bool _get(const StringName& p_name,Variant &r_ret) const;
Expand Down
Loading

0 comments on commit c79be97

Please sign in to comment.