summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/freetype/SCsub3
-rw-r--r--modules/gdscript/gd_compiler.h13
-rw-r--r--modules/gdscript/gd_editor.cpp208
-rw-r--r--modules/gdscript/gd_function.cpp20
-rw-r--r--modules/gdscript/gd_script.cpp104
-rw-r--r--modules/gdscript/gd_tokenizer.cpp50
-rw-r--r--modules/gdscript/register_types.cpp103
-rw-r--r--modules/gridmap/grid_map.cpp510
-rw-r--r--modules/gridmap/grid_map.h39
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp99
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h5
-rw-r--r--modules/openssl/stream_peer_openssl.cpp19
-rw-r--r--modules/svg/SCsub3
-rw-r--r--modules/theora/video_stream_theora.cpp151
14 files changed, 430 insertions, 897 deletions
diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub
index 6a89e8e087..f22df4407c 100644
--- a/modules/freetype/SCsub
+++ b/modules/freetype/SCsub
@@ -1,6 +1,7 @@
#!/usr/bin/env python
Import('env')
+from compat import isbasestring
# Not building in a separate env as scene needs it
@@ -74,7 +75,7 @@ if (env['builtin_freetype'] != 'no'):
# and then plain strings for system library. We insert between the two.
inserted = False
for idx, linklib in enumerate(env["LIBS"]):
- if isinstance(linklib, basestring): # first system lib such as "X11", otherwise SCons lib object
+ if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object
env["LIBS"].insert(idx, lib)
inserted = True
break
diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h
index 5caa3b0ee1..ac713ae75b 100644
--- a/modules/gdscript/gd_compiler.h
+++ b/modules/gdscript/gd_compiler.h
@@ -91,7 +91,6 @@ class GDCompiler {
}
}
- //int get_identifier_pos(const StringName& p_dentifier) const;
HashMap<Variant, int, VariantHasher, VariantComparator> constant_map;
Map<StringName, int> name_map;
@@ -127,17 +126,6 @@ class GDCompiler {
int call_max;
};
-#if 0
- void _create_index(const GDParser::OperatorNode *on);
- void _create_call(const GDParser::OperatorNode *on);
-
-
- int _parse_expression(const GDParser::Node *p_expr,CodeGen& codegen);
- void _parse_block(GDParser::BlockNode *p_block);
- void _parse_function(GDParser::FunctionNode *p_func);
- Ref<GDScript> _parse_class(GDParser::ClassNode *p_class);
-#endif
-
bool _is_class_member_property(CodeGen &codegen, const StringName &p_name);
bool _is_class_member_property(GDScript *owner, const StringName &p_name);
@@ -146,7 +134,6 @@ class GDCompiler {
bool _create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level);
bool _create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false);
- //int _parse_subexpression(CodeGen& codegen,const GDParser::BlockNode *p_block,const GDParser::Node *p_expression);
int _parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level);
int _parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false);
Error _parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 349918f317..b10694ddfd 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -27,12 +27,14 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "gd_script.h"
+
#include "editor/editor_settings.h"
#include "gd_compiler.h"
-#include "gd_script.h"
#include "global_constants.h"
#include "os/file_access.h"
#include "project_settings.h"
+
#ifdef TOOLS_ENABLED
#include "editor/editor_file_system.h"
#include "editor/editor_settings.h"
@@ -363,7 +365,7 @@ struct GDCompletionIdentifier {
Variant value; //im case there is a value, also return it
};
-static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) {
+static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) {
GDCompletionIdentifier t;
t.type = p_variant.get_type();
@@ -371,14 +373,14 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) {
if (p_variant.get_type() == Variant::OBJECT) {
Object *obj = p_variant;
if (obj) {
- /*
- if (Object::cast_to<GDNativeClass>(obj)) {
- t.obj_type=Object::cast_to<GDNativeClass>(obj)->get_name();
- t.value=Variant();
+
+ if (p_allow_gdnative_class && Object::cast_to<GDNativeClass>(obj)) {
+ t.obj_type = Object::cast_to<GDNativeClass>(obj)->get_name();
+ t.value = Variant();
} else {
- */
- t.obj_type = obj->get_class();
- //}
+
+ t.obj_type = obj->get_class();
+ }
}
}
return t;
@@ -511,9 +513,9 @@ static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) {
return id;
}
-static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type);
+static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing);
-static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type) {
+static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type, bool p_for_indexing = false) {
if (p_node->type == GDParser::Node::TYPE_CONSTANT) {
@@ -564,7 +566,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
return true;
} else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) {
- return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type);
+ return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing);
} else if (p_node->type == GDParser::Node::TYPE_SELF) {
//eeh...
@@ -575,6 +577,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node);
if (op->op == GDParser::OperatorNode::OP_CALL) {
+
if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]);
@@ -587,21 +590,45 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
} else if (op->arguments.size() > 1 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name;
+
+ if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && String(id) == "new") {
+
+ //shortcut
+ StringName identifier = static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name;
+
+ if (ClassDB::class_exists(identifier)) {
+ r_type.type = Variant::OBJECT;
+ r_type.value = Variant();
+ r_type.obj_type = identifier;
+ return true;
+ }
+ }
+
GDCompletionIdentifier base;
if (!_guess_expression_type(context, op->arguments[0], p_line, base))
return false;
- StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name;
-
if (base.type == Variant::OBJECT) {
if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) {
+
Object *obj = base.value;
- if (GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj)) {
+ if (obj && Object::cast_to<GDNativeClass>(obj)) {
+ GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj);
r_type.type = Variant::OBJECT;
r_type.value = Variant();
r_type.obj_type = gdnc->get_name();
return true;
+ } else {
+
+ if (base.obj_type != StringName()) {
+
+ r_type.type = Variant::OBJECT;
+ r_type.value = Variant();
+ r_type.obj_type = base.obj_type;
+ return true;
+ }
}
}
@@ -810,23 +837,38 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
if (p1.value.get_type() == Variant::OBJECT) {
//??
+
if (p1.obj_type != StringName() && p2.type == Variant::STRING) {
+
+ StringName base_type = p1.obj_type;
+
+ if (p1.obj_type == "GDNativeClass") {
+ //native enum
+ Ref<GDNativeClass> gdn = p1.value;
+ if (gdn.is_valid()) {
+
+ base_type = gdn->get_name();
+ }
+ }
StringName index = p2.value;
bool valid;
- Variant::Type t = ClassDB::get_property_type(p1.obj_type, index, &valid);
+ Variant::Type t = ClassDB::get_property_type(base_type, index, &valid);
if (t != Variant::NIL && valid) {
r_type.type = t;
- if (t == Variant::INT) {
+ if (t == Variant::INT || t == Variant::OBJECT) {
//check for enum!
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
- StringName getter = ClassDB::get_property_getter(p1.obj_type, index);
+ StringName getter = ClassDB::get_property_getter(base_type, index);
if (getter != StringName()) {
- MethodBind *mb = ClassDB::get_method(p1.obj_type, getter);
+ MethodBind *mb = ClassDB::get_method(base_type, getter);
if (mb) {
PropertyInfo rt = mb->get_return_info();
- if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
+ if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM && t == Variant::INT) {
r_type.enumeration = rt.class_name;
+ } else if (t == Variant::OBJECT) {
+
+ r_type.obj_type = rt.class_name;
}
}
}
@@ -1054,7 +1096,7 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c
return false;
}
-static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) {
+static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing) {
//go to block first
@@ -1208,7 +1250,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) {
if (E->key() == p_identifier) {
- r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()]);
+ r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()], !p_for_indexing);
return true;
}
}
@@ -1672,21 +1714,6 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
return; //found
}
}
-#if 0
- //use class directly, no code was found
- if (!isfunction) {
- for (const Map<StringName,Variant>::Element *E=scr->get_constants().front();E;E=E->next()) {
- options.insert(E->key());
- }
- }
- for (const Map<StringName,GDFunction>::Element *E=scr->get_member_functions().front();E;E=E->next()) {
- options.insert(String(E->key())+"(");
- }
-
- for (const Set<StringName>::Element *E=scr->get_members().front();E;E=E->next()) {
- options.insert(E->get());
- }
-#endif
}
if (scr->get_base().is_valid())
@@ -2027,99 +2054,6 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
}
}
}
-#if 0
- bool _static=context.function->_static;
-
-
-
-
- for(int i=0;i<context._class->static_functions.size();i++) {
- if (context._class->static_functions[i]->arguments.size())
- result.insert(context._class->static_functions[i]->name.operator String()+"(");
- else
- result.insert(context._class->static_functions[i]->name.operator String()+"()");
- }
-
- if (!p_static) {
-
- for(int i=0;i<context._class->functions.size();i++) {
- if (context._class->functions[i]->arguments.size())
- result.insert(context._class->functions[i]->name.operator String()+"(");
- else
- result.insert(context._class->functions[i]->name.operator String()+"()");
- }
- }
-
- Ref<Reference> base = _get_parent_class(context);
-
- while(true) {
-
- Ref<GDScript> script = base;
- Ref<GDNativeClass> nc = base;
- if (script.is_valid()) {
-
- if (!p_static && !p_only_functions) {
- for (const Set<StringName>::Element *E=script->get_members().front();E;E=E->next()) {
- result.insert(E->get().operator String());
- }
- }
-
- if (!p_only_functions) {
- for (const Map<StringName,Variant>::Element *E=script->get_constants().front();E;E=E->next()) {
- result.insert(E->key().operator String());
- }
- }
-
- for (const Map<StringName,GDFunction>::Element *E=script->get_member_functions().front();E;E=E->next()) {
- if (!p_static || E->get().is_static()) {
- if (E->get().get_argument_count())
- result.insert(E->key().operator String()+"(");
- else
- result.insert(E->key().operator String()+"()");
- }
- }
-
- if (!p_only_functions) {
- for (const Map<StringName,Ref<GDScript> >::Element *E=script->get_subclasses().front();E;E=E->next()) {
- result.insert(E->key().operator String());
- }
- }
-
- base=script->get_base();
- if (base.is_null())
- base=script->get_native();
- } else if (nc.is_valid()) {
-
- if (!p_only_functions) {
-
- StringName type = nc->get_name();
- List<String> constants;
- ClassDB::get_integer_constant_list(type,&constants);
- for(List<String>::Element *E=constants.front();E;E=E->next()) {
- result.insert(E->get());
- }
-
- List<MethodInfo> methods;
- ClassDB::get_method_list(type,&methods);
- for(List<MethodInfo>::Element *E=methods.front();E;E=E->next()) {
- if (E->get().arguments.size())
- result.insert(E->get().name+"(");
- else
- result.insert(E->get().name+"()");
- }
- }
- break;
- } else
- break;
-
- }
-
- for(int i=0;i<GDFunctions::FUNC_MAX;i++) {
-
- result.insert(GDFunctions::get_func_name(GDFunctions::Function(i)));
- }
-
-#endif
}
Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) {
@@ -2188,7 +2122,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
break;
GDCompletionIdentifier t;
- if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) {
+ if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) {
if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") {
//native enum
@@ -2852,18 +2786,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
}
-#if 0
- GDCompletionIdentifier identifier;
- if (_guess_identifier_type(context,p.get_completion_line(),p_symbol,identifier)) {
-
- print_line("var type: "+Variant::get_type_name(identifier.type));
- if (identifier.script.is_valid()) {
- print_line("var script: "+identifier.script->get_path());
- }
- print_line("obj type: "+String(identifier.obj_type));
- print_line("value: "+String(identifier.value));
- }
-#endif
}
} break;
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index 0c9eca894f..e6f65fe0c2 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -1319,22 +1319,6 @@ void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName,
}
}
-#if 0
-void GDFunction::clear() {
-
- name=StringName();
- constants.clear();
- _stack_size=0;
- code.clear();
- _constants_ptr=NULL;
- _constant_count=0;
- _global_names_ptr=NULL;
- _global_names_count=0;
- _code_ptr=NULL;
- _code_size=0;
-
-}
-#endif
GDFunction::GDFunction()
: function_list(this) {
@@ -1434,7 +1418,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
// If the return value is a GDFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
- GDFunctionState *gdfs = Object::cast_to<GDFunctionState>((Object *)&ret);
+ GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret);
if (gdfs && gdfs->function == function)
completed = false;
}
@@ -1490,7 +1474,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
// If the return value is a GDFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
- GDFunctionState *gdfs = Object::cast_to<GDFunctionState>((Object *)&ret);
+ GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret);
if (gdfs && gdfs->function == function)
completed = false;
}
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 476fca6382..cf6529d5ae 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gd_script.h"
+
#include "gd_compiler.h"
#include "global_constants.h"
#include "io/file_access_encrypted.h"
@@ -42,11 +43,6 @@ GDNativeClass::GDNativeClass(const StringName &p_name) {
name = p_name;
}
-/*void GDNativeClass::call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount){
-
-
-}*/
-
bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
bool ok;
@@ -183,7 +179,6 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
bool GDScript::can_instance() const {
- //return valid; //any script in GDscript can instance
return valid || (!tool && !ScriptServer::is_scripting_enabled());
}
@@ -218,49 +213,6 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
placeholders.erase(p_placeholder);
}
-
-/*
-void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {
-
-
- List<PropertyInfo> plist;
- GDScript *scr=this;
-
- Map<StringName,Variant> default_values;
- while(scr) {
-
- Vector<_GDScriptMemberSort> msort;
- for(Map<StringName,PropertyInfo>::Element *E=scr->member_info.front();E;E=E->next()) {
-
- _GDScriptMemberSort ms;
- ERR_CONTINUE(!scr->member_indices.has(E->key()));
- ms.index=scr->member_indices[E->key()].index;
- ms.name=E->key();
-
- msort.push_back(ms);
-
- }
-
- msort.sort();
- msort.invert();
- for(int i=0;i<msort.size();i++) {
-
- plist.push_front(scr->member_info[msort[i].name]);
- if (scr->member_default_values.has(msort[i].name))
- default_values[msort[i].name]=scr->member_default_values[msort[i].name];
- else {
- Variant::CallError err;
- default_values[msort[i].name]=Variant::construct(scr->member_info[msort[i].name].type,NULL,0,err);
- }
- }
-
- scr=scr->_base;
- }
-
-
- p_placeholder->update(plist,default_values);
-
-}*/
#endif
void GDScript::get_script_method_list(List<MethodInfo> *p_list) const {
@@ -428,7 +380,6 @@ void GDScript::set_source_code(const String &p_code) {
source = p_code;
#ifdef TOOLS_ENABLED
source_changed_cache = true;
-//print_line("SC CHANGED "+get_path());
#endif
}
@@ -655,12 +606,6 @@ Error GDScript::reload(bool p_keep_state) {
_set_subclass_path(E->get(), path);
}
-#ifdef TOOLS_ENABLED
-/*for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) {
-
- _update_placeholder(E->get());
- }*/
-#endif
return OK;
}
@@ -1141,53 +1086,10 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
props.push_front(sptr->member_info[msort[i].name]);
}
-#if 0
- if (sptr->member_functions.has("_get_property_list")) {
-
- Variant::CallError err;
- GDFunction *f = const_cast<GDFunction*>(sptr->member_functions["_get_property_list"]);
- Variant plv = f->call(const_cast<GDInstance*>(this),NULL,0,err);
-
- if (plv.get_type()!=Variant::ARRAY) {
-
- ERR_PRINT("_get_property_list: expected array returned");
- } else {
-
- Array pl=plv;
-
- for(int i=0;i<pl.size();i++) {
-
- Dictionary p = pl[i];
- PropertyInfo pinfo;
- if (!p.has("name")) {
- ERR_PRINT("_get_property_list: expected 'name' key of type string.")
- continue;
- }
- if (!p.has("type")) {
- ERR_PRINT("_get_property_list: expected 'type' key of type integer.")
- continue;
- }
- pinfo.name=p["name"];
- pinfo.type=Variant::Type(int(p["type"]));
- if (p.has("hint"))
- pinfo.hint=PropertyHint(int(p["hint"]));
- if (p.has("hint_string"))
- pinfo.hint_string=p["hint_string"];
- if (p.has("usage"))
- pinfo.usage=p["usage"];
-
-
- props.push_back(pinfo);
- }
- }
- }
-#endif
sptr = sptr->_base;
}
- //props.invert();
-
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
p_properties->push_back(E->get());
@@ -1390,10 +1292,6 @@ GDInstance::~GDInstance() {
}
/************* SCRIPT LANGUAGE **************/
-/************* SCRIPT LANGUAGE **************/
-/************* SCRIPT LANGUAGE **************/
-/************* SCRIPT LANGUAGE **************/
-/************* SCRIPT LANGUAGE **************/
GDScriptLanguage *GDScriptLanguage::singleton = NULL;
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp
index 6ab7361c92..5f85158232 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gd_tokenizer.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gd_tokenizer.h"
+
#include "gd_functions.h"
#include "io/marshalls.h"
#include "map.h"
@@ -504,7 +505,6 @@ void GDTokenizerText::_advance() {
_make_newline(i);
return;
}
-#if 1 //py style tokenizer
case '#': { // line comment skip
while (GETCHAR(0) != '\n') {
@@ -526,57 +526,9 @@ void GDTokenizerText::_advance() {
return;
} break;
-#endif
case '/': {
switch (GETCHAR(1)) {
-#if 0 // c style tokenizer
- case '*': { // block comment
- int pos = code_pos+2;
- int new_line=line;
- int new_col=column+2;
-
- while(true) {
- if (_code[pos]=='0') {
- _make_error("Unterminated Comment");
- code_pos=pos;
- return;
- }
- if (_code[pos]=='*' && _code[pos+1]=='/') {
- new_col+=2;
- pos+=2; //compensate
- break;
- } else if (_code[pos]=='\n') {
- new_line++;
- new_col=1;
- } else {
- new_col++;
- }
- pos++;
- }
-
- column=new_col;
- line=new_line;
- code_pos=pos;
- continue;
-
- } break;
- case '/': { // line comment skip
-
- while(GETCHAR(0)!='\n') {
- code_pos++;
- if (GETCHAR(0)==0) { //end of file
- _make_error("Unterminated Comment");
- return;
- }
- }
- INCPOS(1);
- column=1;
- line++;
- continue;
-
- } break;
-#endif
case '=': { // diveq
_make_token(TK_OP_ASSIGN_DIV);
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 2354c4063e..036274c8f2 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -37,103 +37,7 @@
GDScriptLanguage *script_language_gd = NULL;
ResourceFormatLoaderGDScript *resource_loader_gd = NULL;
ResourceFormatSaverGDScript *resource_saver_gd = NULL;
-#if 0
-#ifdef TOOLS_ENABLED
-#include "editor/editor_import_export.h"
-#include "editor/editor_node.h"
-#include "editor/editor_settings.h"
-#include "gd_tokenizer.h"
-
-class EditorExportGDScript : public EditorExportPlugin {
-
- GDCLASS(EditorExportGDScript,EditorExportPlugin);
-
-public:
-
- virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) {
- //compile gdscript to bytecode
-
- if (EditorImportExport::get_singleton()->script_get_action()!=EditorImportExport::SCRIPT_ACTION_NONE) {
-
- if (p_path.ends_with(".gd")) {
- Vector<uint8_t> file = FileAccess::get_file_as_array(p_path);
- if (file.empty())
- return file;
- String txt;
- txt.parse_utf8((const char*)file.ptr(),file.size());
- file = GDTokenizerBuffer::parse_code_string(txt);
-
- if (!file.empty()) {
-
- if (EditorImportExport::get_singleton()->script_get_action()==EditorImportExport::SCRIPT_ACTION_ENCRYPT) {
-
- String tmp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/script.gde");
- FileAccess *fa = FileAccess::open(tmp_path,FileAccess::WRITE);
- String skey=EditorImportExport::get_singleton()->script_get_encryption_key().to_lower();
- Vector<uint8_t> key;
- key.resize(32);
- for(int i=0;i<32;i++) {
- int v=0;
- if (i*2<skey.length()) {
- CharType ct = skey[i*2];
- if (ct>='0' && ct<='9')
- ct=ct-'0';
- else if (ct>='a' && ct<='f')
- ct=10+ct-'a';
- v|=ct<<4;
- }
-
- if (i*2+1<skey.length()) {
- CharType ct = skey[i*2+1];
- if (ct>='0' && ct<='9')
- ct=ct-'0';
- else if (ct>='a' && ct<='f')
- ct=10+ct-'a';
- v|=ct;
- }
- key[i]=v;
- }
- FileAccessEncrypted *fae=memnew(FileAccessEncrypted);
- Error err = fae->open_and_parse(fa,key,FileAccessEncrypted::MODE_WRITE_AES256);
- if (err==OK) {
-
- fae->store_buffer(file.ptr(),file.size());
- p_path=p_path.get_basename()+".gde";
- }
-
- memdelete(fae);
-
- file=FileAccess::get_file_as_array(tmp_path);
- return file;
-
-
- } else {
-
- p_path=p_path.get_basename()+".gdc";
- return file;
- }
- }
-
- }
- }
-
- return Vector<uint8_t>();
- }
-
-
- EditorExportGDScript(){}
-
-};
-
-static void register_editor_plugin() {
-
- Ref<EditorExportGDScript> egd = memnew( EditorExportGDScript );
- EditorImportExport::get_singleton()->add_export_plugin(egd);
-}
-
-#endif
-#endif
void register_gdscript_types() {
ClassDB::register_class<GDScript>();
@@ -146,13 +50,8 @@ void register_gdscript_types() {
ResourceLoader::add_resource_format_loader(resource_loader_gd);
resource_saver_gd = memnew(ResourceFormatSaverGDScript);
ResourceSaver::add_resource_format_saver(resource_saver_gd);
-#if 0
-#ifdef TOOLS_ENABLED
-
- EditorNode::add_init_callback(register_editor_plugin);
-#endif
-#endif
}
+
void unregister_gdscript_types() {
ScriptServer::unregister_language(script_language_gd);
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 30aee5b741..0de2cf80ea 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -46,7 +46,13 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
set_theme(p_value);
} else if (name == "cell_size") {
- set_cell_size(p_value);
+ if (p_value.get_type() == Variant::INT || p_value.get_type() == Variant::REAL) {
+ //compatibility
+ float cs = p_value;
+ set_cell_size(Vector3(cs, cs, cs));
+ } else {
+ set_cell_size(p_value);
+ }
} else if (name == "cell_octant_size") {
set_octant_size(p_value);
} else if (name == "cell_center_x") {
@@ -176,12 +182,12 @@ Ref<MeshLibrary> GridMap::get_theme() const {
return theme;
}
-void GridMap::set_cell_size(float p_size) {
+void GridMap::set_cell_size(const Vector3 &p_size) {
cell_size = p_size;
_recreate_octant_data();
}
-float GridMap::get_cell_size() const {
+Vector3 GridMap::get_cell_size() const {
return cell_size;
}
@@ -242,56 +248,29 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
ok.y = p_y / octant_size;
ok.z = p_z / octant_size;
- if (cell_map.has(key)) {
-
- int prev_item = cell_map[key].item;
-
- OctantKey octantkey = ok;
-
- ERR_FAIL_COND(!octant_map.has(octantkey));
- Octant &g = *octant_map[octantkey];
- ERR_FAIL_COND(!g.items.has(prev_item));
- ERR_FAIL_COND(!g.items[prev_item].cells.has(key));
-
- g.items[prev_item].cells.erase(key);
- if (g.items[prev_item].cells.size() == 0) {
- VS::get_singleton()->free(g.items[prev_item].multimesh_instance);
- g.items.erase(prev_item);
- }
- if (g.items.empty()) {
-
- PhysicsServer::get_singleton()->free(g.static_body);
- if (g.collision_debug.is_valid()) {
- PhysicsServer::get_singleton()->free(g.collision_debug);
- PhysicsServer::get_singleton()->free(g.collision_debug_instance);
- }
-
- memdelete(&g);
- octant_map.erase(octantkey);
- } else {
+ if (p_item < 0) {
+ //erase
+ if (cell_map.has(key)) {
+ OctantKey octantkey = ok;
+ ERR_FAIL_COND(!octant_map.has(octantkey));
+ Octant &g = *octant_map[octantkey];
+ g.cells.erase(key);
g.dirty = true;
+ cell_map.erase(key);
+ _queue_octants_dirty();
}
- cell_map.erase(key);
-
- _queue_dirty_map();
- }
-
- if (p_item < 0)
return;
+ }
OctantKey octantkey = ok;
- //add later
if (!octant_map.has(octantkey)) {
-
+ //create octant because it does not exist
Octant *g = memnew(Octant);
g->dirty = true;
g->static_body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
- if (is_inside_world())
- PhysicsServer::get_singleton()->body_set_space(g->static_body, get_world()->get_space());
-
SceneTree *st = SceneTree::get_singleton();
if (st && st->is_debugging_collisions_hint()) {
@@ -299,45 +278,26 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
g->collision_debug = VisualServer::get_singleton()->mesh_create();
g->collision_debug_instance = VisualServer::get_singleton()->instance_create();
VisualServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug);
- if (is_inside_world()) {
- VisualServer::get_singleton()->instance_set_scenario(g->collision_debug_instance, get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_transform(g->collision_debug_instance, get_global_transform());
- }
}
octant_map[octantkey] = g;
- }
-
- Octant &g = *octant_map[octantkey];
- if (!g.items.has(p_item)) {
- Octant::ItemInstances ii;
- if (theme.is_valid() && theme->has_item(p_item)) {
- ii.mesh = theme->get_item_mesh(p_item);
- ii.shape = theme->get_item_shape(p_item);
- ii.navmesh = theme->get_item_navmesh(p_item);
+ if (is_inside_world()) {
+ _octant_enter_world(octantkey);
+ _octant_transform(octantkey);
}
- ii.multimesh = Ref<MultiMesh>(memnew(MultiMesh));
- ii.multimesh->set_color_format(MultiMesh::COLOR_NONE);
- ii.multimesh->set_transform_format(MultiMesh::TRANSFORM_3D);
- ii.multimesh->set_mesh(ii.mesh);
- ii.multimesh_instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(ii.multimesh_instance, ii.multimesh->get_rid());
- VS::get_singleton()->instance_geometry_set_flag(ii.multimesh_instance, VS::INSTANCE_FLAG_USE_BAKED_LIGHT, true);
-
- g.items[p_item] = ii;
}
- Octant::ItemInstances &ii = g.items[p_item];
- ii.cells.insert(key);
+ Octant &g = *octant_map[octantkey];
+ g.cells.insert(key);
g.dirty = true;
+ _queue_octants_dirty();
- _queue_dirty_map();
-
- cell_map[key] = Cell();
- Cell &c = cell_map[key];
+ Cell c;
c.item = p_item;
c.rot = p_rot;
+
+ cell_map[key] = c;
}
int GridMap::get_cell_item(int p_x, int p_y, int p_z) const {
@@ -372,115 +332,57 @@ int GridMap::get_cell_item_orientation(int p_x, int p_y, int p_z) const {
return cell_map[key].rot;
}
-void GridMap::_octant_enter_tree(const OctantKey &p_key) {
- ERR_FAIL_COND(!octant_map.has(p_key));
- if (navigation) {
- Octant &g = *octant_map[p_key];
-
- Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z));
- _octant_clear_navmesh(p_key);
-
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
- Octant::ItemInstances &ii = E->get();
-
- for (Set<IndexKey>::Element *F = ii.cells.front(); F; F = F->next()) {
-
- IndexKey ik = F->get();
- Map<IndexKey, Cell>::Element *C = cell_map.find(ik);
- ERR_CONTINUE(!C);
-
- Vector3 cellpos = Vector3(ik.x, ik.y, ik.z);
-
- Transform xform;
-
- if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) {
-
- xform.basis.set_zero();
-
- } else {
-
- xform.basis.set_orthogonal_index(C->get().rot);
- }
-
- xform.set_origin(cellpos * cell_size + ofs);
- xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
- // add the item's navmesh at given xform to GridMap's Navigation ancestor
- if (ii.navmesh.is_valid()) {
- int nm_id = navigation->navmesh_create(ii.navmesh, xform, this);
- Octant::NavMesh nm;
- nm.id = nm_id;
- nm.xform = xform;
- g.navmesh_ids[ik] = nm;
- }
- }
- }
- }
-}
-
-void GridMap::_octant_enter_world(const OctantKey &p_key) {
+void GridMap::_octant_transform(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space());
- //print_line("BODYPOS: "+get_global_transform());
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
}
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
- VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(E->get().multimesh_instance, get_global_transform());
- //print_line("INSTANCEPOS: "+get_global_transform());
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
+ VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
}
}
-void GridMap::_octant_transform(const OctantKey &p_key) {
-
- ERR_FAIL_COND(!octant_map.has(p_key));
+bool GridMap::_octant_update(const OctantKey &p_key) {
+ ERR_FAIL_COND_V(!octant_map.has(p_key), false);
Octant &g = *octant_map[p_key];
- PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
+ if (!g.dirty)
+ return false;
- if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
- }
+ //erase body shapes
+ PhysicsServer::get_singleton()->body_clear_shapes(g.static_body);
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
+ //erase body shapes debug
+ if (g.collision_debug.is_valid()) {
- VS::get_singleton()->instance_set_transform(E->get().multimesh_instance, get_global_transform());
- //print_line("UPDATEPOS: "+get_global_transform());
+ VS::get_singleton()->mesh_clear(g.collision_debug);
}
-}
-void GridMap::_octant_clear_navmesh(const OctantKey &p_key) {
- Octant &g = *octant_map[p_key];
+ //erase navigation
if (navigation) {
for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
- Octant::NavMesh *nvm = &E->get();
- if (nvm && nvm->id) {
- navigation->navmesh_remove(E->get().id);
- }
+ navigation->navmesh_remove(E->get().id);
}
g.navmesh_ids.clear();
}
-}
-
-void GridMap::_octant_update(const OctantKey &p_key) {
- ERR_FAIL_COND(!octant_map.has(p_key));
- Octant &g = *octant_map[p_key];
- if (!g.dirty)
- return;
- Ref<Mesh> mesh;
+ //erase multimeshes
- _octant_clear_navmesh(p_key);
- PhysicsServer::get_singleton()->body_clear_shapes(g.static_body);
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
- if (g.collision_debug.is_valid()) {
+ VS::get_singleton()->free(g.multimesh_instances[i].instance);
+ VS::get_singleton()->free(g.multimesh_instances[i].multimesh);
+ }
+ g.multimesh_instances.clear();
- VS::get_singleton()->mesh_clear(g.collision_debug);
+ if (g.cells.size() == 0) {
+ //octant no longer needed
+ _octant_clean_up(p_key);
+ return true;
}
PoolVector<Vector3> col_debug;
@@ -490,80 +392,111 @@ void GridMap::_octant_update(const OctantKey &p_key) {
* set item's multimesh's instance count to number of cells which have this item
* and set said multimesh bounding box to one containing all cells which have this item
*/
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
- Octant::ItemInstances &ii = E->get();
+ Map<int, List<Pair<Transform, IndexKey> > > multimesh_items;
- ii.multimesh->set_instance_count(ii.cells.size());
+ print_line("updating octant " + itos(p_key.x) + ", " + itos(p_key.y) + ", " + itos(p_key.z) + " cells: " + itos(g.cells.size()));
- Rect3 aabb;
- Rect3 mesh_aabb = ii.mesh.is_null() ? Rect3() : ii.mesh->get_aabb();
+ for (Set<IndexKey>::Element *E = g.cells.front(); E; E = E->next()) {
- Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z));
+ ERR_CONTINUE(!cell_map.has(E->get()));
+ const Cell &c = cell_map[E->get()];
+
+ if (!theme.is_valid() || !theme->has_item(c.item))
+ continue;
//print_line("OCTANT, CELLS: "+itos(ii.cells.size()));
- int idx = 0;
- // foreach cell containing this item type
- for (Set<IndexKey>::Element *F = ii.cells.front(); F; F = F->next()) {
- IndexKey ik = F->get();
- Map<IndexKey, Cell>::Element *C = cell_map.find(ik);
- ERR_CONTINUE(!C);
- Vector3 cellpos = Vector3(ik.x, ik.y, ik.z);
+ Vector3 cellpos = Vector3(E->get().x, E->get().y, E->get().z);
+ Vector3 ofs(cell_size.x * 0.5 * int(center_x), cell_size.y * 0.5 * int(center_y), cell_size.z * 0.5 * int(center_z));
- Transform xform;
+ Transform xform;
- if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) {
+ if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) {
- xform.basis.set_zero();
+ } else {
+ }
- } else {
+ xform.basis.set_orthogonal_index(c.rot);
+ xform.set_origin(cellpos * cell_size + ofs);
+ xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
- xform.basis.set_orthogonal_index(C->get().rot);
+ if (theme->get_item_mesh(c.item).is_valid()) {
+ if (!multimesh_items.has(c.item)) {
+ multimesh_items[c.item] = List<Pair<Transform, IndexKey> >();
}
- xform.set_origin(cellpos * cell_size + ofs);
- xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
+ Pair<Transform, IndexKey> p;
+ p.first = xform;
+ p.second = E->get();
+ multimesh_items[c.item].push_back(p);
+ }
- ii.multimesh->set_instance_transform(idx, xform);
- //ii.multimesh->set_instance_transform(idx,Transform() );
- //ii.multimesh->set_instance_color(idx,Color(1,1,1,1));
- //print_line("MMINST: "+xform);
+ Vector<MeshLibrary::ShapeData> shapes = theme->get_item_shapes(c.item);
+ // add the item's shape at given xform to octant's static_body
+ for (int i = 0; i < shapes.size(); i++) {
+ // add the item's shape
+ if (!shapes[i].shape.is_valid())
+ continue;
+ PhysicsServer::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform);
+ if (g.collision_debug.is_valid()) {
+ shapes[i].shape->add_vertices_to_array(col_debug, xform * shapes[i].local_transform);
+ }
- if (idx == 0) {
+ //print_line("PHIS x: "+xform);
+ }
- aabb = xform.xform(mesh_aabb);
- } else {
+ // add the item's navmesh at given xform to GridMap's Navigation ancestor
+ Ref<NavigationMesh> navmesh = theme->get_item_navmesh(c.item);
+ if (navmesh.is_valid()) {
+ Octant::NavMesh nm;
+ nm.xform = xform;
- aabb.merge_with(xform.xform(mesh_aabb));
+ if (navigation) {
+ nm.id = navigation->navmesh_create(navmesh, xform, this);
+ } else {
+ nm.id = -1;
}
+ g.navmesh_ids[E->get()] = nm;
+ }
+ }
- // add the item's shape at given xform to octant's static_body
- if (ii.shape.is_valid()) {
- // add the item's shape
- PhysicsServer::get_singleton()->body_add_shape(g.static_body, ii.shape->get_rid(), xform);
- if (g.collision_debug.is_valid()) {
- ii.shape->add_vertices_to_array(col_debug, xform);
- }
+ //update multimeshes
+ for (Map<int, List<Pair<Transform, IndexKey> > >::Element *E = multimesh_items.front(); E; E = E->next()) {
+ print_line("multimesh item " + itos(E->key()) + " transforms " + itos(E->get().size()));
+ Octant::MultimeshInstance mmi;
- //print_line("PHIS x: "+xform);
- }
+ RID mm = VS::get_singleton()->multimesh_create();
+ VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE);
+ VS::get_singleton()->multimesh_set_mesh(mm, theme->get_item_mesh(E->key())->get_rid());
- // add the item's navmesh at given xform to GridMap's Navigation ancestor
- if (navigation) {
- if (ii.navmesh.is_valid()) {
- int nm_id = navigation->navmesh_create(ii.navmesh, xform, this);
- Octant::NavMesh nm;
- nm.id = nm_id;
- nm.xform = xform;
- g.navmesh_ids[ik] = nm;
- }
- }
+ int idx = 0;
+ for (List<Pair<Transform, IndexKey> >::Element *F = E->get().front(); F; F = F->next()) {
+ VS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first);
+#ifdef TOOLS_ENABLED
+
+ Octant::MultimeshInstance::Item it;
+ it.index = idx;
+ it.transform = F->get().first;
+ it.key = F->get().second;
+ mmi.items.push_back(it);
+#endif
idx++;
}
- //ii.multimesh->set_aabb(aabb);
+ RID instance = VS::get_singleton()->instance_create();
+ VS::get_singleton()->instance_set_base(instance, mm);
+
+ if (is_inside_tree()) {
+ VS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(instance, get_global_transform());
+ }
+
+ mmi.multimesh = mm;
+ mmi.instance = instance;
+
+ g.multimesh_instances.push_back(mmi);
}
if (col_debug.size()) {
@@ -580,6 +513,39 @@ void GridMap::_octant_update(const OctantKey &p_key) {
}
g.dirty = false;
+
+ return false;
+}
+
+void GridMap::_octant_enter_world(const OctantKey &p_key) {
+
+ ERR_FAIL_COND(!octant_map.has(p_key));
+ Octant &g = *octant_map[p_key];
+ PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space());
+ //print_line("BODYPOS: "+get_global_transform());
+
+ if (g.collision_debug_instance.is_valid()) {
+ VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
+ }
+
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
+ VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
+ }
+
+ if (navigation && theme.is_valid()) {
+ for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
+
+ if (cell_map.has(F->key()) && F->get().id < 0) {
+ Ref<NavigationMesh> nm = theme->get_item_navmesh(cell_map[F->key()].item);
+ if (nm.is_valid()) {
+ F->get().id = navigation->navmesh_create(nm, F->get().xform, this);
+ }
+ }
+ }
+ }
}
void GridMap::_octant_exit_world(const OctantKey &p_key) {
@@ -594,30 +560,73 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
}
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
+ VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID());
+ }
+
+ if (navigation) {
+ for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
- VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, RID());
- //VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
+ if (F->get().id >= 0) {
+ navigation->navmesh_remove(F->get().id);
+ F->get().id = -1;
+ }
+ }
}
}
+void GridMap::_octant_clean_up(const OctantKey &p_key) {
+
+ ERR_FAIL_COND(!octant_map.has(p_key));
+ Octant &g = *octant_map[p_key];
+
+ if (g.collision_debug.is_valid())
+ VS::get_singleton()->free(g.collision_debug);
+ if (g.collision_debug_instance.is_valid())
+ VS::get_singleton()->free(g.collision_debug_instance);
+
+ PhysicsServer::get_singleton()->free(g.static_body);
+
+ //erase navigation
+ if (navigation) {
+ for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
+ navigation->navmesh_remove(E->get().id);
+ }
+ g.navmesh_ids.clear();
+ }
+
+ //erase multimeshes
+
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
+
+ VS::get_singleton()->free(g.multimesh_instances[i].instance);
+ VS::get_singleton()->free(g.multimesh_instances[i].multimesh);
+ }
+ g.multimesh_instances.clear();
+}
+
void GridMap::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
- for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- //IndexKey ik;
- //ik.key = E->key().indexkey;
- _octant_enter_world(E->key());
- _octant_update(E->key());
- }
+ Spatial *c = this;
+ while (c) {
+ navigation = Object::cast_to<Navigation>(c);
+ if (navigation) {
+ break;
+ }
- awaiting_update = false;
+ c = Object::cast_to<Spatial>(c->get_parent());
+ }
last_transform = get_global_transform();
+ for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
+ _octant_enter_world(E->key());
+ }
+
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -638,56 +647,23 @@ void GridMap::_notification(int p_what) {
_octant_exit_world(E->key());
}
- //_queue_dirty_map(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS);
- //_update_dirty_map_callback();
- //_update_area_instances();
-
- } break;
- case NOTIFICATION_ENTER_TREE: {
-
- Spatial *c = this;
- while (c) {
- navigation = Object::cast_to<Navigation>(c);
- if (navigation) {
- break;
- }
-
- c = Object::cast_to<Spatial>(c->get_parent());
- }
-
- if (navigation) {
- for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- if (navigation) {
- _octant_enter_tree(E->key());
- }
- }
- }
-
- _queue_dirty_map();
- } break;
- case NOTIFICATION_EXIT_TREE: {
- for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- if (navigation) {
- _octant_clear_navmesh(E->key());
- }
- }
-
navigation = NULL;
+ //_queue_octants_dirty(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS);
+ //_update_octants_callback();
+ //_update_area_instances();
+
} break;
}
}
-void GridMap::_queue_dirty_map() {
+void GridMap::_queue_octants_dirty() {
if (awaiting_update)
return;
- if (is_inside_world()) {
-
- MessageQueue::get_singleton()->push_call(this, "_update_dirty_map_callback");
- awaiting_update = true;
- }
+ MessageQueue::get_singleton()->push_call(this, "_update_octants_callback");
+ awaiting_update = true;
}
void GridMap::_recreate_octant_data() {
@@ -706,17 +682,7 @@ void GridMap::_clear_internal() {
if (is_inside_world())
_octant_exit_world(E->key());
- for (Map<int, Octant::ItemInstances>::Element *F = E->get()->items.front(); F; F = F->next()) {
-
- VS::get_singleton()->free(F->get().multimesh_instance);
- }
-
- if (E->get()->collision_debug.is_valid())
- VS::get_singleton()->free(E->get()->collision_debug);
- if (E->get()->collision_debug_instance.is_valid())
- VS::get_singleton()->free(E->get()->collision_debug_instance);
-
- PhysicsServer::get_singleton()->free(E->get()->static_body);
+ _octant_clean_up(E->key());
memdelete(E->get());
}
@@ -734,13 +700,23 @@ void GridMap::resource_changed(const RES &p_res) {
_recreate_octant_data();
}
-void GridMap::_update_dirty_map_callback() {
+void GridMap::_update_octants_callback() {
if (!awaiting_update)
return;
+ List<OctantKey> to_delete;
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- _octant_update(E->key());
+
+ if (_octant_update(E->key())) {
+ to_delete.push_back(E->key());
+ }
+ }
+
+ while (to_delete.front()) {
+ memdelete(octant_map[to_delete.front()->get()]);
+ octant_map.erase(to_delete.front()->get());
+ to_delete.pop_back();
}
awaiting_update = false;
@@ -762,7 +738,7 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_cell_item_orientation", "x", "y", "z"), &GridMap::get_cell_item_orientation);
//ClassDB::bind_method(D_METHOD("_recreate_octants"),&GridMap::_recreate_octants);
- ClassDB::bind_method(D_METHOD("_update_dirty_map_callback"), &GridMap::_update_dirty_map_callback);
+ ClassDB::bind_method(D_METHOD("_update_octants_callback"), &GridMap::_update_octants_callback);
ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &GridMap::resource_changed);
ClassDB::bind_method(D_METHOD("set_center_x", "enable"), &GridMap::set_center_x);
@@ -800,13 +776,13 @@ void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3::
g->dirty = true;
}
awaiting_update = true;
- _update_dirty_map_callback();
+ _update_octants_callback();
}
void GridMap::set_cell_scale(float p_scale) {
cell_scale = p_scale;
- _queue_dirty_map();
+ _queue_octants_dirty();
}
float GridMap::get_cell_scale() const {
@@ -819,7 +795,7 @@ Array GridMap::get_meshes() {
if (theme.is_null())
return Array();
- Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z));
+ Vector3 ofs(cell_size.x * 0.5 * int(center_x), cell_size.y * 0.5 * int(center_y), cell_size.z * 0.5 * int(center_z));
Array meshes;
for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) {
@@ -851,7 +827,7 @@ Array GridMap::get_meshes() {
GridMap::GridMap() {
- cell_size = 2;
+ cell_size = Vector3(2, 2, 2);
octant_size = 4;
awaiting_update = false;
_in_tree = false;
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index e97e9adabe..9e1d250680 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -38,8 +38,6 @@
//heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done..
//should scale better with hardware that supports instancing
-class BakedLightInstance;
-
class GridMap : public Spatial {
GDCLASS(GridMap, Spatial);
@@ -96,21 +94,25 @@ class GridMap : public Spatial {
Transform xform;
};
- struct ItemInstances {
- Set<IndexKey> cells;
- Ref<Mesh> mesh;
- Ref<Shape> shape;
- Ref<MultiMesh> multimesh;
- RID multimesh_instance;
- Ref<NavigationMesh> navmesh;
+ struct MultimeshInstance {
+ RID instance;
+ RID multimesh;
+ struct Item {
+ int index;
+ Transform transform;
+ IndexKey key;
+ };
+
+ Vector<Item> items; //tools only, for changing visibility
};
+ Vector<MultimeshInstance> multimesh_instances;
+ Set<IndexKey> cells;
RID collision_debug;
RID collision_debug_instance;
bool dirty;
RID static_body;
- Map<int, ItemInstances> items;
Map<IndexKey, NavMesh> navmesh_ids;
};
@@ -137,7 +139,7 @@ class GridMap : public Spatial {
Transform last_transform;
bool _in_tree;
- float cell_size;
+ Vector3 cell_size;
int octant_size;
bool center_x, center_y, center_z;
float cell_scale;
@@ -169,15 +171,14 @@ class GridMap : public Spatial {
}
void _octant_enter_world(const OctantKey &p_key);
- void _octant_enter_tree(const OctantKey &p_key);
void _octant_exit_world(const OctantKey &p_key);
- void _octant_update(const OctantKey &p_key);
+ bool _octant_update(const OctantKey &p_key);
+ void _octant_clean_up(const OctantKey &p_key);
void _octant_transform(const OctantKey &p_key);
- void _octant_clear_navmesh(const GridMap::OctantKey &);
bool awaiting_update;
- void _queue_dirty_map();
- void _update_dirty_map_callback();
+ void _queue_octants_dirty();
+ void _update_octants_callback();
void resource_changed(const RES &p_res);
@@ -199,8 +200,8 @@ public:
void set_theme(const Ref<MeshLibrary> &p_theme);
Ref<MeshLibrary> get_theme() const;
- void set_cell_size(float p_size);
- float get_cell_size() const;
+ void set_cell_size(const Vector3 &p_size);
+ Vector3 get_cell_size() const;
void set_octant_size(int p_size);
int get_octant_size() const;
@@ -229,4 +230,4 @@ public:
~GridMap();
};
-#endif // CUBE_GRID_MAP_H
+#endif // GRID_MAP_H
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index bf7bcf1fd8..6f0a13e07f 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -217,12 +217,15 @@ void GridMapEditor::_update_cursor_transform() {
}
void GridMapEditor::_update_selection_transform() {
+ Transform xf_zero;
+ xf_zero.basis.set_zero();
if (!selection.active) {
- Transform xf;
- xf.basis.set_zero();
- VisualServer::get_singleton()->instance_set_transform(selection_instance, xf);
+ VisualServer::get_singleton()->instance_set_transform(selection_instance, xf_zero);
+ for (int i = 0; i < 3; i++) {
+ VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
+ }
return;
}
@@ -231,6 +234,27 @@ void GridMapEditor::_update_selection_transform() {
xf.origin = selection.begin * node->get_cell_size();
VisualServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf);
+
+ for (int i = 0; i < 3; i++) {
+ if (i != edit_axis || (edit_floor[edit_axis] < selection.begin[edit_axis]) || (edit_floor[edit_axis] > selection.end[edit_axis] + 1)) {
+ VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
+ } else {
+
+ Vector3 scale = (selection.end - selection.begin + Vector3(1, 1, 1));
+ scale[edit_axis] = 1.0;
+ Vector3 pos = selection.begin;
+ pos[edit_axis] = edit_floor[edit_axis];
+
+ scale *= node->get_cell_size();
+ pos *= node->get_cell_size();
+
+ Transform xf;
+ xf.basis.scale(scale);
+ xf.origin = pos;
+
+ VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf);
+ }
+ }
}
void GridMapEditor::_validate_selection() {
@@ -273,7 +297,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
Plane p;
p.normal[edit_axis] = 1.0;
- p.d = edit_floor[edit_axis] * node->get_cell_size();
+ p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
Vector3 inters;
if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters))
@@ -289,7 +313,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
}
int cell[3];
- float cell_size[3] = { node->get_cell_size(), node->get_cell_size(), node->get_cell_size() };
+ float cell_size[3] = { node->get_cell_size().x, node->get_cell_size().y, node->get_cell_size().z };
last_mouseover = Vector3(-1, -1, -1);
@@ -299,7 +323,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
cell[i] = edit_floor[i];
else {
- cell[i] = inters[i] / node->get_cell_size();
+ cell[i] = inters[i] / node->get_cell_size()[i];
if (inters[i] < 0)
cell[i] -= 1; //compensate negative
grid_ofs[i] = cell[i] * cell_size[i];
@@ -717,6 +741,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
//update grids
indicator_mat.instance();
indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
indicator_mat->set_albedo(Color(0.8, 0.5, 0.1));
@@ -724,7 +749,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
Vector<Vector3> grid_points[3];
Vector<Color> grid_colors[3];
- float cell_size[3] = { p_gridmap->get_cell_size(), p_gridmap->get_cell_size(), p_gridmap->get_cell_size() };
+ float cell_size[3] = { p_gridmap->get_cell_size().x, p_gridmap->get_cell_size().y, p_gridmap->get_cell_size().z };
for (int i = 0; i < 3; i++) {
@@ -788,7 +813,7 @@ void GridMapEditor::update_grid() {
//VS *vs = VS::get_singleton();
- grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size();
+ grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
edit_grid_xform.origin = grid_ofs;
edit_grid_xform.basis = Basis();
@@ -811,6 +836,7 @@ void GridMapEditor::_notification(int p_what) {
grid[i] = VS::get_singleton()->mesh_create();
grid_instance[i] = VS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
+ selection_level_instance[i] = VisualServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario());
}
selection_instance = VisualServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario());
@@ -827,6 +853,7 @@ void GridMapEditor::_notification(int p_what) {
VS::get_singleton()->free(grid[i]);
grid_instance[i] = RID();
grid[i] = RID();
+ VisualServer::get_singleton()->free(selection_level_instance[i]);
}
VisualServer::get_singleton()->free(selection_instance);
@@ -858,7 +885,7 @@ void GridMapEditor::_notification(int p_what) {
Plane p;
p.normal[edit_axis] = 1.0;
- p.d = edit_floor[edit_axis] * node->get_cell_size();
+ p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
p = node->get_transform().xform(p); // plane to snap
SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
@@ -906,6 +933,7 @@ void GridMapEditor::_floor_changed(float p_value) {
node->set_meta("_editor_floor_", Vector3(edit_floor[0], edit_floor[1], edit_floor[2]));
update_grid();
_update_clip();
+ _update_selection_transform();
}
void GridMapEditor::_bind_methods() {
@@ -1047,6 +1075,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
PoolVector<Vector3> lines;
PoolVector<Vector3> triangles;
+ PoolVector<Vector3> square[3];
for (int i = 0; i < 6; i++) {
@@ -1086,12 +1115,41 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
lines.push_back(b);
}
+ for (int i = 0; i < 3; i++) {
+ Vector3 points[4];
+ for (int j = 0; j < 4; j++) {
+
+ static const bool orderx[4] = { 0, 1, 1, 0 };
+ static const bool ordery[4] = { 0, 0, 1, 1 };
+
+ Vector3 sp;
+ if (orderx[j]) {
+ sp[(i + 1) % 3] = 1.0;
+ }
+ if (ordery[j]) {
+ sp[(i + 2) % 3] = 1.0;
+ }
+
+ points[j] = sp;
+ }
+
+ for (int j = 0; j < 4; j++) {
+
+ Vector3 ofs;
+ ofs[i] += 0.01;
+ square[i].push_back(points[j] - ofs);
+ square[i].push_back(points[(j + 1) % 4] - ofs);
+ square[i].push_back(points[j] + ofs);
+ square[i].push_back(points[(j + 1) % 4] + ofs);
+ }
+ }
+
Array d;
d.resize(VS::ARRAY_MAX);
inner_mat.instance();
- inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.3));
- inner_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+ inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2));
+ //inner_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
inner_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
inner_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
@@ -1100,12 +1158,19 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
outer_mat.instance();
- outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.3));
+ outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
outer_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
outer_mat->set_line_width(3.0);
outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ selection_floor_mat.instance();
+ selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1));
+ selection_floor_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+ selection_floor_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ selection_floor_mat->set_line_width(3.0);
+ //selection_floor_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+
d[VS::ARRAY_VERTEX] = lines;
VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d);
VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid());
@@ -1117,6 +1182,13 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
d[VS::ARRAY_VERTEX] = lines;
VisualServer::get_singleton()->mesh_add_surface_from_arrays(duplicate_mesh, VS::PRIMITIVE_LINES, d);
VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh, 1, outer_mat->get_rid());
+
+ for (int i = 0; i < 3; i++) {
+ d[VS::ARRAY_VERTEX] = square[i];
+ selection_level_mesh[i] = VS::get_singleton()->mesh_create();
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], VS::PRIMITIVE_LINES, d);
+ VisualServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid());
+ }
}
selection.active = false;
@@ -1133,6 +1205,9 @@ GridMapEditor::~GridMapEditor() {
VisualServer::get_singleton()->free(grid_instance[i]);
if (cursor_instance.is_valid())
VisualServer::get_singleton()->free(cursor_instance);
+ if (selection_level_instance[i].is_valid()) {
+ VisualServer::get_singleton()->free(selection_level_instance[i]);
+ }
}
VisualServer::get_singleton()->free(selection_mesh);
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index b2c28c4f77..ecbfbf2d65 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -109,12 +109,15 @@ class GridMapEditor : public VBoxContainer {
RID cursor_instance;
RID selection_mesh;
RID selection_instance;
+ RID selection_level_mesh[3];
+ RID selection_level_instance[3];
RID duplicate_mesh;
RID duplicate_instance;
Ref<SpatialMaterial> indicator_mat;
Ref<SpatialMaterial> inner_mat;
Ref<SpatialMaterial> outer_mat;
+ Ref<SpatialMaterial> selection_floor_mat;
bool updating;
@@ -223,7 +226,7 @@ class GridMapEditorPlugin : public EditorPlugin {
EditorNode *editor;
public:
- virtual bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return gridmap_editor->forward_spatial_input_event(p_camera, p_event); }
+ virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return gridmap_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "GridMap"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
diff --git a/modules/openssl/stream_peer_openssl.cpp b/modules/openssl/stream_peer_openssl.cpp
index ce69101302..d40bf73883 100644
--- a/modules/openssl/stream_peer_openssl.cpp
+++ b/modules/openssl/stream_peer_openssl.cpp
@@ -28,15 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "stream_peer_openssl.h"
-//hostname matching code from curl
-//#include <openssl/applink.c> // To prevent crashing (see the OpenSSL FAQ)
+//hostname matching code from curl
bool StreamPeerOpenSSL::_match_host_name(const char *name, const char *hostname) {
return Tool_Curl_cert_hostcheck(name, hostname) == CURL_HOST_MATCH;
- //print_line("MATCH: "+String(name)+" vs "+String(hostname));
- //return true;
}
Error StreamPeerOpenSSL::_match_common_name(const char *hostname, const X509 *server_cert) {
@@ -298,20 +295,6 @@ Error StreamPeerOpenSSL::connect_to_stream(Ref<StreamPeer> p_base, bool p_valida
X509_STORE_add_cert(store, certs[i]);
}
-#if 0
- const unsigned char *in=(const unsigned char *)certs.ptr();
- X509 *Cert = d2i_X509(NULL, &in, certs.size()-1);
- if (!Cert) {
- print_line(String(ERR_error_string(ERR_get_error(),NULL)));
- }
- ERR_FAIL_COND_V(!Cert,ERR_PARSE_ERROR);
-
- X509_STORE *store = SSL_CTX_get_cert_store(ctx);
- X509_STORE_add_cert(store,Cert);
-
- //char *str = X509_NAME_oneline(X509_get_subject_name(Cert),0,0);
- //printf ("subject: %s\n", str); /* [1] */
-#endif
}
//used for testing
diff --git a/modules/svg/SCsub b/modules/svg/SCsub
index 062c26cf10..5be9367808 100644
--- a/modules/svg/SCsub
+++ b/modules/svg/SCsub
@@ -1,6 +1,7 @@
#!/usr/bin/env python
Import('env')
+from compat import isbasestring
# Thirdparty source files
thirdparty_dir = "#thirdparty/nanosvg/"
@@ -18,7 +19,7 @@ lib = env.Library("svg_builtin", thirdparty_sources)
# and then plain strings for system library. We insert between the two.
inserted = False
for idx, linklib in enumerate(env["LIBS"]):
- if isinstance(linklib, basestring): # first system lib such as "X11", otherwise SCons lib object
+ if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object
env["LIBS"].insert(idx, lib)
inserted = True
break
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 1be3f73d09..2a24f8d4d1 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -83,37 +83,6 @@ void VideoStreamPlaybackTheora::video_write(void) {
th_ycbcr_buffer yuv;
th_decode_ycbcr_out(td, yuv);
- // FIXME: The way stuff is commented out with `//*/` closing comments
- // sounds very fishy...
-
- /*
- int y_offset, uv_offset;
- y_offset=(ti.pic_x&~1)+yuv[0].stride*(ti.pic_y&~1);
-
- {
- int pixels = size.x * size.y;
- frame_data.resize(pixels * 4);
- PoolVector<uint8_t>::Write w = frame_data.write();
- char* dst = (char*)w.ptr();
- int p = 0;
- for (int i=0; i<size.y; i++) {
-
- char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i;
- char *out = dst + (int)size.x * 4 * i;
- for (int j=0;j<size.x;j++) {
-
- dst[p++] = in_y[j];
- dst[p++] = in_y[j];
- dst[p++] = in_y[j];
- dst[p++] = 255;
- };
- }
- format = Image::FORMAT_RGBA8;
- }
- //*/
-
- //*
-
int pitch = 4;
frame_data.resize(size.x * size.y * pitch);
{
@@ -142,99 +111,6 @@ void VideoStreamPlaybackTheora::video_write(void) {
texture->set_data(img); //zero copy send to visual server
- /*
-
- if (px_fmt == TH_PF_444) {
-
- int pitch = 3;
- frame_data.resize(size.x * size.y * pitch);
- PoolVector<uint8_t>::Write w = frame_data.write();
- char* dst = (char*)w.ptr();
-
- for(int i=0;i<size.y;i++) {
-
- char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i;
- char *out = dst + (int)size.x * pitch * i;
- char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*i;
- char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*i;
- for (int j=0;j<size.x;j++) {
-
- out[j*3+0] = in_y[j];
- out[j*3+1] = in_u[j];
- out[j*3+2] = in_v[j];
- };
- }
-
- format = Image::FORMAT_YUV_444;
-
- } else {
-
- int div;
- if (px_fmt!=TH_PF_422) {
- div = 2;
- }
-
- bool rgba = true;
- if (rgba) {
-
- int pitch = 4;
- frame_data.resize(size.x * size.y * pitch);
- PoolVector<uint8_t>::Write w = frame_data.write();
- char* dst = (char*)w.ptr();
-
- uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div);
- for(int i=0;i<size.y;i++) {
- char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i;
- char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*(i/div);
- char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*(i/div);
- uint8_t *out = (uint8_t*)dst + (int)size.x * pitch * i;
- int ofs = 0;
- for (int j=0;j<size.x;j++) {
-
- uint8_t y, u, v;
- y = in_y[j];
- u = in_u[j/2];
- v = in_v[j/2];
-
- int32_t r = Math::fast_ftoi(1.164 * (y - 16) + 1.596 * (v - 128));
- int32_t g = Math::fast_ftoi(1.164 * (y - 16) - 0.813 * (v - 128) - 0.391 * (u - 128));
- int32_t b = Math::fast_ftoi(1.164 * (y - 16) + 2.018 * (u - 128));
-
- out[ofs++] = CLAMP(r, 0, 255);
- out[ofs++] = CLAMP(g, 0, 255);
- out[ofs++] = CLAMP(b, 0, 255);
- out[ofs++] = 255;
- }
- }
-
- format = Image::FORMAT_RGBA8;
-
- } else {
-
- int pitch = 2;
- frame_data.resize(size.x * size.y * pitch);
- PoolVector<uint8_t>::Write w = frame_data.write();
- char* dst = (char*)w.ptr();
-
- uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div);
- for(int i=0;i<size.y;i++) {
- char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i;
- char *out = dst + (int)size.x * pitch * i;
- for (int j=0;j<size.x;j++)
- out[j*2] = in_y[j];
- char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*(i/div);
- char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*(i/div);
- for (int j=0;j<(int)size.x>>1;j++) {
- out[j*4+1] = in_u[j];
- out[j*4+3] = in_v[j];
- }
- }
-
- format = Image::FORMAT_YUV_422;
- };
- };
- //*/
-
frames_pending = 1;
}
@@ -455,15 +331,6 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
th_decode_ctl(td, TH_DECCTL_SET_PPLEVEL, &pp_level, sizeof(pp_level));
pp_inc = 0;
- /*{
- int arg = 0xffff;
- th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_MBMODE,&arg,sizeof(arg));
- th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_MV,&arg,sizeof(arg));
- th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_QI,&arg,sizeof(arg));
- arg=10;
- th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_BITS,&arg,sizeof(arg));
- }*/
-
int w;
int h;
w = (ti.pic_x + ti.frame_width + 1 & ~1) - (ti.pic_x & ~1);
@@ -502,8 +369,6 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
float VideoStreamPlaybackTheora::get_time() const {
- //print_line("total: "+itos(get_total())+" todo: "+itos(get_todo()));
- //return MAX(0,time-((get_total())/(float)vi.rate));
return time - AudioServer::get_singleton()->get_output_delay() - delay_compensation; //-((get_total())/(float)vi.rate);
};
@@ -526,8 +391,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
thread_sem->post();
#endif
- //double ctime =AudioServer::get_singleton()->get_mix_time();
-
//print_line("play "+rtos(p_delta));
time += p_delta;
@@ -663,8 +526,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
}
}
-//print_line("no theora: "+itos(no_theora)+" theora eos: "+itos(theora_eos)+" frame done "+itos(frame_done));
-
#ifdef THEORA_USE_THREAD_STREAMING
if (file && thread_eof && no_theora && theora_eos && ring_buffer.data_left() == 0) {
#else
@@ -674,16 +535,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
stop();
return;
};
-#if 0
- if (!videobuf_ready || audio_todo > 0){
- /* no data yet for somebody. Grab another page */
-
- buffer_data();
- while(ogg_sync_pageout(&oy,&og)>0){
- queue_page(&og);
- }
- }
-#else
if (!frame_done || !audio_done) {
//what's the point of waiting for audio to grab a page?
@@ -693,7 +544,7 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
queue_page(&og);
}
}
-#endif
+
/* If playback has begun, top audio buffer off immediately. */
//if(stateflag) audio_write_nonblocking();