Fixing Issues...

- #672 (default user:// in $HOME/.godot/app_userdata (linux/osx) and $APPDATA/Godot/app_userdata (Windows)
- #676 (draw both tiles and octants in order from top to bottom, left to right )
- #686 (unicode escape sequences work now)
- #702 (was not a bug, but a test was added to see if bodies went too far away)
This commit is contained in:
Juan Linietsky 2014-09-19 18:39:50 -03:00
parent 526aae62ed
commit 549d344f0f
22 changed files with 504 additions and 179 deletions

View File

@ -1381,6 +1381,7 @@ Globals::Globals() {
set("application/main_scene","");
custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"xml,res,scn,xscn");
set("application/disable_stdout",false);
set("application/use_shared_user_dir",true);
key.key.scancode=KEY_RETURN;

View File

@ -130,35 +130,46 @@ Error DirAccess::make_dir_recursive(String p_dir) {
if (p_dir.length() < 1) {
return OK;
};
String full_dir;
Globals* g = Globals::get_singleton();
String cur = normalize_path(g->globalize_path(get_current_dir()));
if (cur[cur.length()-1] != '/') {
cur = cur + "/";
};
String dir = normalize_path(g->globalize_path(p_dir));
if (dir.length() < 1) {
return OK;
};
if (dir[dir.length()-1] != '/') {
dir = dir + "/";
};
if (!p_dir.is_abs_path()) {
//append current
ERR_FAIL_COND_V(dir.find(cur) != 0, FAILED);
String cur = normalize_path(g->globalize_path(get_current_dir()));
if (cur[cur.length()-1] != '/') {
cur = cur + "/";
};
String rel = dir.substr(cur.length(), (dir.length() - cur.length()));
full_dir=(cur+"/"+p_dir).simplify_path();
} else {
//validate and use given
String dir = normalize_path(g->globalize_path(p_dir));
if (dir.length() < 1) {
return OK;
};
if (dir[dir.length()-1] != '/') {
dir = dir + "/";
};
full_dir=dir;
}
int slices = full_dir.get_slice_count("/");
int pos = 0;
while (pos < rel.length()) {
while (pos < full_dir.length()) {
int n = rel.find("/", pos);
int n = full_dir.find("/", pos);
if (n < 0) {
n = rel.length();
n = full_dir.length();
};
pos = n + 1;
if (pos > 1) {
Error err = make_dir(rel.substr(0, pos -1));
String to_create = full_dir.substr(0, pos -1);
//print_line("MKDIR: "+to_create);
Error err = make_dir(to_create);
if (err != OK && err != ERR_ALREADY_EXISTS) {
ERR_FAIL_V(err);

View File

@ -386,7 +386,7 @@ void OS::_ensure_data_dir() {
}
da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = da->make_dir(dd);
Error err = da->make_dir_recursive(dd);
if (err!=OK) {
ERR_EXPLAIN("Error attempting to create data dir: "+dd);
}

File diff suppressed because one or more lines are too long

View File

@ -382,9 +382,15 @@ String OS_Unix::get_data_dir() const {
String an = Globals::get_singleton()->get("application/name");
if (an!="") {
if (has_environment("HOME")) {
return get_environment("HOME")+"/."+an;
bool use_godot = Globals::get_singleton()->get("application/use_shared_user_dir");
if (use_godot)
return get_environment("HOME")+"/.godot/app_userdata/"+an;
else
return get_environment("HOME")+"/."+an;
}
}

View File

@ -2089,6 +2089,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export=PropertyInfo();
_set_error("Expected a string constant in enumeration hint.");
return;
}
String c = tokenizer->get_token_constant();
@ -2106,6 +2107,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token()!=GDTokenizer::TK_COMMA) {
current_export=PropertyInfo();
_set_error("Expected ')' or ',' in enumeration hint.");
return;
}
tokenizer->advance();
@ -2122,6 +2124,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export=PropertyInfo();
_set_error("Expected a range in numeric hint.");
return;
}
//enumeration
@ -2139,6 +2142,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export=PropertyInfo();
_set_error("Expected ',' or ')' in numeric range hint.");
return;
}
tokenizer->advance();
@ -2147,6 +2151,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export=PropertyInfo();
_set_error("Expected a number as upper bound in numeric range hint.");
return;
}
current_export.hint_string+=","+tokenizer->get_token_constant().operator String();
@ -2159,6 +2164,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export=PropertyInfo();
_set_error("Expected ',' or ')' in numeric range hint.");
return;
}
tokenizer->advance();
@ -2167,6 +2173,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export=PropertyInfo();
_set_error("Expected a number as step in numeric range hint.");
return;
}
current_export.hint_string+=","+tokenizer->get_token_constant().operator String();
@ -2185,6 +2192,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export=PropertyInfo();
_set_error("Expected a string constant in enumeration hint.");
return;
}
String c = tokenizer->get_token_constant();

View File

@ -565,22 +565,21 @@ void GDTokenizerText::_advance() {
case '\'': res='\''; break;
case '\"': res='\"'; break;
case '\\': res='\\'; break;
case 'x': {
//hexnumbarh - oct is deprecated
case '/': res='/'; break; //wtf
int read=0;
case 'u': {
//hexnumbarh - oct is deprecated
i+=1;
for(int j=0;j<4;j++) {
CharType c = GETCHAR(i+j);
if (c==0) {
_make_error("Unterminated String");
return;
}
if (!_is_hex(c)) {
if (j==0 || !(j&1)) {
_make_error("Malformed hex constant in string");
return;
} else
break;
if (!((c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'))) {
_make_error("Malformed hex constant in string");
return;
}
CharType v;
if (c>='0' && c<='9') {
@ -599,10 +598,9 @@ void GDTokenizerText::_advance() {
res<<=4;
res|=v;
read++;
}
i+=read-1;
}
i+=3;
} break;
default: {

View File

@ -1835,7 +1835,11 @@ String OS_Windows::get_data_dir() const {
if (has_environment("APPDATA")) {
return (OS::get_singleton()->get_environment("APPDATA")+"\\"+an).replace("\\","/"); // windows path to unix path to be consistent with get_resource_path
bool use_godot = Globals::get_singleton()->get("application/use_shared_user_dir");
if (use_godot)
return (OS::get_singleton()->get_environment("APPDATA")+"/"+an).replace("\\","/");
else
return (OS::get_singleton()->get_environment("APPDATA")+"/Godot/app_userdata/"+an).replace("\\","/");
}
}

View File

@ -352,7 +352,7 @@ void Particles2D::_process_particles(float p_delta) {
p.velocity*=param[PARAM_LINEAR_VELOCITY]+param[PARAM_LINEAR_VELOCITY]*_rand_from_seed(&rand_seed)*randomness[PARAM_LINEAR_VELOCITY];
p.velocity+=initial_velocity;
p.active=true;
p.rot=0;
p.rot=Math::deg2rad(param[PARAM_INITIAL_ANGLE]+param[PARAM_INITIAL_ANGLE]*randomness[PARAM_INITIAL_ANGLE]*_rand_from_seed(&rand_seed));
active_count++;
@ -632,6 +632,7 @@ static const char* _particlesframe_property_names[Particles2D::PARAM_MAX]={
"params/radial_accel",
"params/tangential_accel",
"params/damping",
"params/initial_angle",
"params/initial_size",
"params/final_size",
"params/hue_variation"
@ -647,7 +648,8 @@ static const char* _particlesframe_property_rnames[Particles2D::PARAM_MAX]={
"randomness/gravity_strength",
"randomness/radial_accel",
"randomness/tangential_accel",
"randomness/damping",
"randomness/damping",
"randomness/initial_angle",
"randomness/initial_size",
"randomness/final_size",
"randomness/hue_variation"
@ -664,6 +666,7 @@ static const char* _particlesframe_property_ranges[Particles2D::PARAM_MAX]={
"-128,128,0.01",
"-128,128,0.01",
"0,1024,0.001",
"0,360,0.01",
"0,1024,0.01",
"0,1024,0.01",
"0,1,0.01"
@ -1041,6 +1044,7 @@ Particles2D::Particles2D() {
set_param(PARAM_GRAVITY_STRENGTH,9.8);
set_param(PARAM_RADIAL_ACCEL,0);
set_param(PARAM_TANGENTIAL_ACCEL,0);
set_param(PARAM_INITIAL_ANGLE,0.0);
set_param(PARAM_INITIAL_SIZE,1.0);
set_param(PARAM_FINAL_SIZE,1.0);

View File

@ -87,7 +87,7 @@ public:
enum Parameter {
PARAM_DIRECTION,
PARAM_SPREAD,
PARAM_LINEAR_VELOCITY,
PARAM_LINEAR_VELOCITY,
PARAM_SPIN_VELOCITY,
PARAM_ORBIT_VELOCITY,
PARAM_GRAVITY_DIRECTION,
@ -95,6 +95,7 @@ public:
PARAM_RADIAL_ACCEL,
PARAM_TANGENTIAL_ACCEL,
PARAM_DAMPING,
PARAM_INITIAL_ANGLE,
PARAM_INITIAL_SIZE,
PARAM_FINAL_SIZE,
PARAM_HUE_VARIATION,

View File

@ -269,6 +269,20 @@ void TileMap::_update_dirty_quadrants() {
pending_update=false;
if (quadrant_order_dirty) {
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
if (q.canvas_item.is_valid()) {
VS::get_singleton()->canvas_item_raise(q.canvas_item);
}
}
quadrant_order_dirty=false;
}
_recompute_rect_cache();
}
@ -329,6 +343,7 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
q.pos=Vector2(p_qk.x,p_qk.y)*quadrant_size*cell_size;
rect_cache_dirty=true;
quadrant_order_dirty=true;
return quadrant_map.insert(p_qk,q);
}
@ -387,8 +402,9 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y) {
if (!E) {
E=tile_map.insert(pk,Cell());
if (!Q)
if (!Q) {
Q=_create_quadrant(qk);
}
Quadrant &q=Q->get();
q.cells.insert(pk);
} else {
@ -510,6 +526,7 @@ void TileMap::_set_tile_data(const DVector<int>& p_data) {
// if (x<-20 || y <-20 || x>4000 || y>4000)
// continue;
set_cell(x,y,v,flip_h,flip_v);
}
}
@ -658,6 +675,7 @@ TileMap::TileMap() {
rect_cache_dirty=true;
pending_update=false;
quadrant_order_dirty=false;
quadrant_size=16;
cell_size=64;
center_x=false;

View File

@ -50,12 +50,13 @@ class TileMap : public Node2D {
int16_t x;
int16_t y;
};
uint32_t key;
bool operator<(const PosKey& pk) const { return key<pk.key; }
//using a more precise comparison so the regions can be sorted later
bool operator<(const PosKey& p_k) const { return (y==p_k.y) ? x < p_k.x : y < p_k.y; }
PosKey(int16_t p_x, int16_t p_y) { x=p_x; y=p_y; }
PosKey() { key=0; }
PosKey() { x=0; y=0; }
};
@ -97,6 +98,7 @@ class TileMap : public Node2D {
Rect2 rect_cache;
bool rect_cache_dirty;
bool quadrant_order_dirty;
float fp_adjust;
float friction;
float bounce;

View File

@ -438,8 +438,12 @@ Ref<SpatialGizmo> Spatial::get_gizmo() const {
void Spatial::_update_gizmo() {
data.gizmo_dirty=false;
if (data.gizmo.is_valid())
data.gizmo->redraw();
if (data.gizmo.is_valid()) {
if (is_visible())
data.gizmo->redraw();
else
data.gizmo->clear();
}
}
@ -511,6 +515,10 @@ void Spatial::_propagate_visibility_changed() {
notification(NOTIFICATION_VISIBILITY_CHANGED);
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
_change_notify("visibility/visible");
#ifdef TOOLS_ENABLED
if (data.gizmo.is_valid())
_update_gizmo();
#endif
for (List<Spatial*>::Element*E=data.children.front();E;E=E->next()) {

View File

@ -45,6 +45,7 @@ public:
virtual void create()=0;
virtual void transform()=0;
virtual void clear()=0;
virtual void redraw()=0;
virtual void free()=0;

View File

@ -1184,7 +1184,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (k.mod.shift) {
for(int i=0;i<txt.length();i++) {
if (((i>0 && txt[i-1]=='\n') || (i==0 && selection.from_column==0)) && (txt[i]=='\t' || txt[i]==' ')) {
if (((i>0 && txt[i-1]=='\n') || (i==0 /*&& selection.from_column==0*/)) && (txt[i]=='\t' || txt[i]==' ')) {
txt.remove(i);
//i--;
}
@ -1193,7 +1193,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
for(int i=0;i<txt.length();i++) {
if (((i>0 && txt[i-1]=='\n') || (i==0 && selection.from_column==0))) {
if (((i>0 && txt[i-1]=='\n') || (i==0 /*&& selection.from_column==0*/))) {
txt=txt.insert(i,"\t");
//i--;
}

View File

@ -27,11 +27,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "shader_graph.h"
#if 0
void Shader::_set(const String& p_name, const Variant& p_value) {
# if 0
void ShaderGraph::_set(const String& p_name, const Variant& p_value) {
if (p_name.begins_with("nodes/")) {
int idx=p_name.get_slice("/",1).to_int();
@ -39,11 +39,12 @@ void Shader::_set(const String& p_name, const Variant& p_value) {
ERR_FAIL_COND(!data.has("type"));
String type=data["type"];
VS::ShaderNodeType node_type=VS::NODE_TYPE_MAX;
VS::NodeType node_type=VS::NODE_TYPE_MAX;
for(int i=0;i<NODE_TYPE_MAX;i++) {
if (type==VisualServer::shader_node_get_type_info((VS::ShaderNodeType)i).name)
node_type=(VS::ShaderNodeType)i;
if (type==VisualServer::shader_node_get_type_info((VS::NodeType)i).name)
node_type=(VS::NodeType)i;
}
ERR_FAIL_COND(node_type==VS::NODE_TYPE_MAX);
@ -65,13 +66,14 @@ void Shader::_set(const String& p_name, const Variant& p_value) {
connect(data["src_id"],data["src_slot"],data["dst_id"],data["dst_slot"]);
}
return false;
}
Variant Shader::_get(const String& p_name) const {
Variant ShaderGraph::_get(const String& p_name) const {
if (p_name.begins_with("nodes/")) {
int idx=p_name.get_slice("/",1).to_int();
Dictionary data;
data["type"]=VisualServer::shader_node_get_type_info((VS::ShaderNodeType)node_get_type(idx)).name;
data["type"]=VisualServer::shader_node_get_type_info((VS::NodeType)node_get_type(idx)).name;
data["pos"]=node_get_pos(idx);
data["param"]=node_get_param(idx);
return data;
@ -94,7 +96,7 @@ Variant Shader::_get(const String& p_name) const {
return Variant();
}
void Shader::_get_property_list( List<PropertyInfo> *p_list) const {
void ShaderGraph::_get_property_list( List<PropertyInfo> *p_list) const {
List<int> nodes;
get_node_list(&nodes);
@ -114,7 +116,9 @@ void Shader::_get_property_list( List<PropertyInfo> *p_list) const {
}
Array Shader::_get_connections_helper() const {
#endif
#if 0
Array ShaderGraph::_get_connections_helper() const {
Array connections_ret;
List<Connection> connections;
@ -136,23 +140,23 @@ Array Shader::_get_connections_helper() const {
return connections_ret;
}
void Shader::_bind_methods() {
void ShaderGraph::_bind_methods() {
ObjectTypeDB::bind_method(_MD("node_add"),&Shader::node_add );
ObjectTypeDB::bind_method(_MD("node_remove"),&Shader::node_remove );
ObjectTypeDB::bind_method(_MD("node_set_param"),&Shader::node_set_param );
ObjectTypeDB::bind_method(_MD("node_set_pos"),&Shader::node_set_pos );
ObjectTypeDB::bind_method(_MD("node_add"),&ShaderGraph::node_add );
ObjectTypeDB::bind_method(_MD("node_remove"),&ShaderGraph::node_remove );
ObjectTypeDB::bind_method(_MD("node_set_param"),&ShaderGraph::node_set_param );
ObjectTypeDB::bind_method(_MD("node_set_pos"),&ShaderGraph::node_set_pos );
ObjectTypeDB::bind_method(_MD("node_get_pos"),&Shader::node_get_pos );
ObjectTypeDB::bind_method(_MD("node_get_param"),&Shader::node_get_type);
ObjectTypeDB::bind_method(_MD("node_get_type"),&Shader::node_get_param);
ObjectTypeDB::bind_method(_MD("node_get_pos"),&ShaderGraph::node_get_pos );
ObjectTypeDB::bind_method(_MD("node_get_param"),&ShaderGraph::node_get_type);
ObjectTypeDB::bind_method(_MD("node_get_type"),&ShaderGraph::node_get_param);
ObjectTypeDB::bind_method(_MD("connect"),&Shader::connect );
ObjectTypeDB::bind_method(_MD("disconnect"),&Shader::disconnect );
ObjectTypeDB::bind_method(_MD("connect"),&ShaderGraph::connect );
ObjectTypeDB::bind_method(_MD("disconnect"),&ShaderGraph::disconnect );
ObjectTypeDB::bind_method(_MD("get_connections"),&Shader::_get_connections_helper );
ObjectTypeDB::bind_method(_MD("get_connections"),&ShaderGraph::_get_connections_helper );
ObjectTypeDB::bind_method(_MD("clear"),&Shader::clear );
ObjectTypeDB::bind_method(_MD("clear"),&ShaderGraph::clear );
BIND_CONSTANT( NODE_IN ); ///< param 0: name
BIND_CONSTANT( NODE_OUT ); ///< param 0: name
@ -210,57 +214,221 @@ void Shader::_bind_methods() {
BIND_CONSTANT( NODE_TYPE_MAX );
}
void Shader::node_add(NodeType p_type,int p_id) {
void ShaderGraph::node_add(NodeType p_type,int p_id) {
VisualServer::get_singleton()->shader_node_add(shader,(VS::ShaderNodeType)p_type,p_id);
#ifdef TOOLS_ENABLED
positions[p_id]=Point2();
#endif
ERR_FAIL_COND( node_map.has(p_id ) );
ERR_FAIL_INDEX( p_type, NODE_TYPE_MAX );
Node node;
node.type=p_type;
node.id=p_id;
node.x=0;
node.y=0;
node_map[p_id]=node;
}
void ShaderGraph::node_set_pos(int p_id, const Vector2& p_pos) {
ERR_FAIL_COND(!node_map.has(p_id));
node_map[p_id].x=p_pos.x;
node_map[p_id].y=p_pos.y;
}
Vector2 ShaderGraph::node_get_pos(int p_id) const {
ERR_FAIL_COND_V(!node_map.has(p_id),Vector2());
return Vector2(node_map[p_id].x,node_map[p_id].y);
}
void ShaderGraph::node_remove(int p_id) {
ERR_FAIL_COND(!node_map.has(p_id));
//erase connections associated with node
List<Connection>::Element *N,*E=connections.front();
while(E) {
N=E->next();
const Connection &c = E->get();
if (c.src_id==p_id || c.dst_id==p_id) {
connections.erase(E);
}
E=N;
}
node_map.erase(p_id);
}
void ShaderGraph::node_change_type(int p_id, NodeType p_type) {
ERR_FAIL_COND(!node_map.has(p_id));
node_map[p_id].type=p_type;
node_map[p_id].param=Variant();
}
void ShaderGraph::node_set_param(int p_id, const Variant& p_value) {
ERR_FAIL_COND(!node_map.has(p_id));
node_map[p_id].param=p_value;
}
void ShaderGraph::get_node_list(List<int> *p_node_list) const {
Map<int,Node>::Element *E = node_map.front();
while(E) {
p_node_list->push_back(E->key());
E=E->next();
}
}
ShaderGraph::NodeType ShaderGraph::node_get_type(int p_id) const {
ERR_FAIL_COND_V(!node_map.has(p_id),NODE_TYPE_MAX);
return node_map[p_id].type;
}
Variant ShaderGraph::node_get_param(int p_id) const {
ERR_FAIL_COND_V(!node_map.has(p_id),Variant());
return node_map[p_id].param;
}
Error ShaderGraph::connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) {
ERR_FAIL_COND_V(p_src_id==p_dst_id, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!node_map.has(p_src_id), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!node_map.has(p_dst_id), ERR_INVALID_PARAMETER);
NodeType type_src=node_map[p_src_id].type;
NodeType type_dst=node_map[p_dst_id].type;
//ERR_FAIL_INDEX_V( p_src_slot, VisualServer::shader_get_output_count(type_src), ERR_INVALID_PARAMETER );
//ERR_FAIL_INDEX_V( p_dst_slot, VisualServer::shader_get_input_count(type_dst), ERR_INVALID_PARAMETER );
//ERR_FAIL_COND_V(VisualServer::shader_is_output_vector(type_src,p_src_slot) != VisualServer::shader_is_input_vector(type_dst,p_dst_slot), ERR_INVALID_PARAMETER );
List<Connection>::Element *E=connections.front();
while(E) {
const Connection &c = E->get();
ERR_FAIL_COND_V(c.dst_slot==p_dst_slot && c.dst_id == p_dst_id, ERR_ALREADY_EXISTS);
E=E->next();
}
Connection c;
c.src_slot=p_src_slot;
c.src_id=p_src_id;
c.dst_slot=p_dst_slot;
c.dst_id=p_dst_id;
connections.push_back(c);
return OK;
}
bool ShaderGraph::is_connected(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) const {
const List<Connection>::Element *E=connections.front();
while(E) {
const Connection &c = E->get();
if (c.dst_slot==p_dst_slot && c.dst_id == p_dst_id && c.src_slot==p_src_slot && c.src_id == p_src_id)
return true;
E=E->next();
}
return false;
}
void ShaderGraph::disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) {
List<Connection>::Element *N,*E=connections.front();
while(E) {
N=E->next();
const Connection &c = E->get();
if (c.src_slot==p_src_slot && c.src_id==p_src_id && c.dst_slot==p_dst_slot && c.dst_id == p_dst_id) {
connections.erase(E);
}
E=N;
}
}
void ShaderGraph::get_connections(List<Connection> *p_connections) const {
const List<Connection>::Element*E=connections.front();
while(E) {
p_connections->push_back(E->get());
E=E->next();
}
}
void ShaderGraph::clear() {
connections.clear();
node_map.clear();
}
#if 0
void ShaderGraph::node_add(NodeType p_type,int p_id) {
ShaderNode sn;
sn.type=p_type;
nodes[p_id]=sn;
version++;
}
void Shader::node_remove(int p_id) {
void ShaderGraph::node_remove(int p_id) {
VisualServer::get_singleton()->shader_node_remove(shader,p_id);
#ifdef TOOLS_ENABLED
positions.erase(p_id);
#endif
nodes.erase(p_id);
}
void Shader::node_set_param( int p_id, const Variant& p_value) {
void ShaderGraph::node_set_param( int p_id, const Variant& p_value) {
VisualServer::get_singleton()->shader_node_set_param(shader,p_id,p_value);
version++;
}
void Shader::get_node_list(List<int> *p_node_list) const {
void ShaderGraph::get_node_list(List<int> *p_node_list) const {
VisualServer::get_singleton()->shader_get_node_list(shader,p_node_list);
}
Shader::NodeType Shader::node_get_type(int p_id) const {
ShaderGraph::NodeType ShaderGraph::node_get_type(int p_id) const {
return (NodeType)VisualServer::get_singleton()->shader_node_get_type(shader,p_id);
}
Variant Shader::node_get_param(int p_id) const {
Variant ShaderGraph::node_get_param(int p_id) const {
return VisualServer::get_singleton()->shader_node_get_param(shader,p_id);
}
void Shader::connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) {
void ShaderGraph::connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) {
VisualServer::get_singleton()->shader_connect(shader,p_src_id,p_src_slot,p_dst_id,p_dst_slot);
version++;
}
void Shader::disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) {
void ShaderGraph::disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) {
VisualServer::get_singleton()->shader_disconnect(shader,p_src_id,p_src_slot,p_dst_id,p_dst_slot);
version++;
}
void Shader::get_connections(List<Connection> *p_connections) const {
void ShaderGraph::get_connections(List<Connection> *p_connections) const {
List<VS::ShaderConnection> connections;
List<VS::ShaderGraphConnection> connections;
VisualServer::get_singleton()->shader_get_connections(shader,&connections);
for( List<VS::ShaderConnection>::Element *E=connections.front();E;E=E->next()) {
for( List<VS::ShaderGraphConnection>::Element *E=connections.front();E;E=E->next()) {
Connection c;
c.src_id=E->get().src_id;
@ -271,7 +439,7 @@ void Shader::get_connections(List<Connection> *p_connections) const {
}
}
void Shader::node_set_pos(int p_id,const Point2& p_pos) {
void ShaderGraph::node_set_pos(int p_id,const Point2& p_pos) {
#ifdef TOOLS_ENABLED
ERR_FAIL_COND(!positions.has(p_id));
@ -279,36 +447,33 @@ void Shader::node_set_pos(int p_id,const Point2& p_pos) {
#endif
}
Point2 Shader::node_get_pos(int p_id) const {
Point2 ShaderGraph::node_get_pos(int p_id) const {
#ifdef TOOLS_ENABLED
ERR_FAIL_COND_V(!positions.has(p_id),Point2());
return positions[p_id];
#endif
}
void Shader::clear() {
void ShaderGraph::clear() {
VisualServer::get_singleton()->shader_clear(shader);
version++;
}
#endif
Shader::Shader() {
ShaderGraph::ShaderGraph() {
shader = VisualServer::get_singleton()->shader_create();
//shader = VisualServer::get_singleton()->shader_create();
version = 1;
}
Shader::~Shader() {
ShaderGraph::~ShaderGraph() {
VisualServer::get_singleton()->free(shader);
//VisualServer::get_singleton()->free(shader);
}
ShaderGraph::ShaderGraph()
{
}
void VisualServer::shader_get_default_input_nodes(ShaderType p_type,List<PropertyInfo> *p_inputs) {
#if 0
void ShaderGraph::shader_get_default_input_nodes(Mode p_type,List<PropertyInfo> *p_inputs) {
switch(p_type) {
@ -341,7 +506,7 @@ void VisualServer::shader_get_default_input_nodes(ShaderType p_type,List<Propert
}
}
void VisualServer::shader_get_default_output_nodes(ShaderType p_type,List<PropertyInfo> *p_outputs) {
void ShaderGraph::shader_get_default_output_nodes(ShaderGraphType p_type,List<PropertyInfo> *p_outputs) {
switch(p_type) {
@ -377,7 +542,7 @@ void VisualServer::shader_get_default_output_nodes(ShaderType p_type,List<Proper
}
PropertyInfo VisualServer::shader_node_get_type_info(ShaderNodeType p_type) {
PropertyInfo ShaderGraph::shader_node_get_type_info(NodeType p_type) {
switch(p_type) {
@ -446,7 +611,7 @@ PropertyInfo VisualServer::shader_node_get_type_info(ShaderNodeType p_type) {
ERR_FAIL_V( PropertyInfo(Variant::NIL,"error") );
}
int VisualServer::shader_get_input_count(ShaderNodeType p_type) {
int ShaderGraph::shader_get_input_count(NodeType p_type) {
switch(p_type) {
case NODE_IN: return 0;
@ -511,7 +676,7 @@ int VisualServer::shader_get_input_count(ShaderNodeType p_type) {
}
ERR_FAIL_V( 0 );
}
int VisualServer::shader_get_output_count(ShaderNodeType p_type) {
int ShaderGraph::shader_get_output_count(NodeType p_type) {
switch(p_type) {
case NODE_IN: return 1;
@ -585,7 +750,7 @@ int VisualServer::shader_get_output_count(ShaderNodeType p_type) {
#define RET5(m_a,m_b,m_c,m_d,m_e) if (p_idx==0) return m_a; else if (p_idx==1) return m_b; else if (p_idx==2) return m_c; else if (p_idx==3) return m_d; else if (p_idx==4) return m_e; else return "";
String VisualServer::shader_get_input_name(ShaderNodeType p_type,int p_idx) {
String ShaderGraph::shader_get_input_name(NodeType p_type,int p_idx) {
switch(p_type) {
@ -653,7 +818,7 @@ String VisualServer::shader_get_input_name(ShaderNodeType p_type,int p_idx) {
ERR_FAIL_V("");
}
String VisualServer::shader_get_output_name(ShaderNodeType p_type,int p_idx) {
String ShaderGraph::shader_get_output_name(NodeType p_type,int p_idx) {
switch(p_type) {
@ -721,7 +886,7 @@ String VisualServer::shader_get_output_name(ShaderNodeType p_type,int p_idx) {
ERR_FAIL_V("");
}
bool VisualServer::shader_is_input_vector(ShaderNodeType p_type,int p_input) {
bool ShaderGraph::shader_is_input_vector(NodeType p_type,int p_input) {
switch(p_type) {
@ -789,7 +954,7 @@ bool VisualServer::shader_is_input_vector(ShaderNodeType p_type,int p_input) {
ERR_FAIL_V(false);
}
bool VisualServer::shader_is_output_vector(ShaderNodeType p_type,int p_input) {
bool ShaderGraph::shader_is_output_vector(NodeType p_type,int p_input) {
switch(p_type) {
@ -858,5 +1023,5 @@ bool VisualServer::shader_is_output_vector(ShaderNodeType p_type,int p_input) {
ERR_FAIL_V("");
}
#endif
#endif

View File

@ -29,28 +29,15 @@
#ifndef SHADER_GRAPH_H
#define SHADER_GRAPH_H
#include "map.h"
#if 0
class Shader : public Resource {
#include "map.h"
#include "scene/resources/shader.h"
OBJ_TYPE( Shader, Resource );
class ShaderGraph : public Resource {
OBJ_TYPE( ShaderGraph, Resource );
RES_BASE_EXTENSION("sgp");
RID shader;
Map<int,Point2> positions;
uint64_t version;
protected:
bool _set(const StringName& p_name, const Variant& p_value);
bool _get(const StringName& p_name,Variant &r_ret) const;
void _get_property_list( List<PropertyInfo> *p_list) const;
static void _bind_methods();
Array _get_connections_helper() const;
public:
@ -116,18 +103,13 @@ public:
NODE_TYPE_MAX
};
void node_add(NodeType p_type,int p_id);
void node_remove(int p_id);
void node_set_param( int p_id, const Variant& p_value);
void node_set_pos(int p_id,const Point2& p_pos);
Point2 node_get_pos(int p_id) const;
enum ShaderType {
SHADER_VERTEX,
SHADER_FRAGMENT,
SHADER_LIGHT
};
void get_node_list(List<int> *p_node_list) const;
NodeType node_get_type(int p_id) const;
Variant node_get_param(int p_id) const;
void connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot);
void disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot);
private:
struct Connection {
@ -137,40 +119,79 @@ public:
int dst_slot;
};
void get_connections(List<Connection> *p_connections) const;
struct Node {
int16_t x,y;
NodeType type;
Variant param;
int id;
mutable int order; // used for sorting
mutable bool out_valid;
mutable bool in_valid;
};
struct ShaderData {
Map<int,Node> node_map;
List<Connection> connections;
} shader[3];
uint64_t version;
protected:
/* bool _set(const StringName& p_name, const Variant& p_value);
bool _get(const StringName& p_name,Variant &r_ret) const;
void _get_property_list( List<PropertyInfo> *p_list) const;*/
static void _bind_methods();
Array _get_connections_helper() const;
public:
void node_add(ShaderType p_which, NodeType p_type,int p_id);
void node_remove(ShaderType p_which,int p_id);
void node_set_param(ShaderType p_which, int p_id, const Variant& p_value);
void node_set_pos(ShaderType p_which,int p_id,const Point2& p_pos);
void node_change_type(ShaderType p_which,int p_id, NodeType p_type);
Point2 node_get_pos(ShaderType p_which,int p_id) const;
void get_node_list(ShaderType p_which,List<int> *p_node_list) const;
NodeType node_get_type(ShaderType p_which,int p_id) const;
Variant node_get_param(ShaderType p_which,int p_id) const;
Error connect(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot);
bool is_connected(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) const;
void disconnect(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot);
void get_connections(ShaderType p_which,List<Connection> *p_connections) const;
void clear();
virtual RID get_rid() const { return shader; }
uint64_t get_version() const { return version; }
Shader();
~Shader();
static void get_default_input_nodes(Mode p_type,List<PropertyInfo> *p_inputs);
static void get_default_output_nodes(Mode p_type,List<PropertyInfo> *p_outputs);
static PropertyInfo node_get_type_info(NodeType p_type);
static int get_input_count(NodeType p_type);
static int get_output_count(NodeType p_type);
static String get_input_name(NodeType p_type,int p_input);
static String get_output_name(NodeType p_type,int p_output);
static bool is_input_vector(NodeType p_type,int p_input);
static bool is_output_vector(NodeType p_type,int p_input);
ShaderGraph();
~ShaderGraph();
};
enum ShaderType {
SHADER_VERTEX,
SHADER_FRAGMENT,
SHADER_POST_PROCESS
};
//helper functions
static void shader_get_default_input_nodes(ShaderType p_type,List<PropertyInfo> *p_inputs);
static void shader_get_default_output_nodes(ShaderType p_type,List<PropertyInfo> *p_outputs);
static PropertyInfo shader_node_get_type_info(ShaderNodeType p_type);
static int shader_get_input_count(ShaderNodeType p_type);
static int shader_get_output_count(ShaderNodeType p_type);
static String shader_get_input_name(ShaderNodeType p_type,int p_input);
static String shader_get_output_name(ShaderNodeType p_type,int p_output);
static bool shader_is_input_vector(ShaderNodeType p_type,int p_input);
static bool shader_is_output_vector(ShaderNodeType p_type,int p_input);
VARIANT_ENUM_CAST( Shader::NodeType );
VARIANT_ENUM_CAST( ShaderGraph::NodeType );
#endif
#endif // SHADER_GRAPH_H

View File

@ -34,6 +34,9 @@
#include "self_list.h"
#include "broad_phase_sw.h"
#define MAX_OBJECT_DISTANCE 10000000
#define MAX_OBJECT_DISTANCE_X2 (MAX_OBJECT_DISTANCE*MAX_OBJECT_DISTANCE)
class SpaceSW;
class CollisionObjectSW : public ShapeOwnerSW {
@ -72,7 +75,19 @@ protected:
void _update_shapes_with_motion(const Vector3& p_motion);
void _unregister_shapes();
_FORCE_INLINE_ void _set_transform(const Transform& p_transform,bool p_update_shapes=true) { transform=p_transform; if (p_update_shapes) _update_shapes(); }
_FORCE_INLINE_ void _set_transform(const Transform& p_transform,bool p_update_shapes=true) {
#ifdef DEBUG_ENABLED
if (p_transform.origin.length_squared() > MAX_OBJECT_DISTANCE_X2) {
ERR_EXPLAIN("Object went too far away (more than "+itos(MAX_OBJECT_DISTANCE)+"mts from origin).");
ERR_FAIL();
}
#endif
transform=p_transform; if (p_update_shapes) _update_shapes();
}
_FORCE_INLINE_ void _set_inv_transform(const Transform& p_transform) { inv_transform=p_transform; }
void _set_static(bool p_static);

View File

@ -180,6 +180,7 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform&
}
concave_B->cull(local_aabb,concave_callback,&cinfo);
//print_line("COL AABB TESTS: "+itos(cinfo.aabb_tests));
return cinfo.collided;
}
@ -346,6 +347,8 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A,const Transform&
}
//print_line("DIST AABB TESTS: "+itos(cinfo.aabb_tests));
return !cinfo.collided;
} else {

View File

@ -2086,7 +2086,19 @@ void SpatialEditorViewport::_bind_methods(){
}
void SpatialEditorViewport::reset() {
orthogonal=false;
message_time=0;
message="";
last_message="";
cursor.x_rot=0;
cursor.y_rot=0;
cursor.distance=4;
cursor.region_select=false;
}
SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
@ -3270,6 +3282,34 @@ void SpatialEditor::_bind_methods() {
ADD_SIGNAL( MethodInfo("transform_key_request") );
}
void SpatialEditor::clear() {
settings_fov->set_text(EDITOR_DEF("3d_editor/default_fov",60.0));
settings_znear->set_text(EDITOR_DEF("3d_editor/default_z_near",0.1));
settings_zfar->set_text(EDITOR_DEF("3d_editor/default_z_far",1500.0));
for(int i=0;i<4;i++) {
viewports[i]->reset();
}
_menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
_menu_item_pressed(MENU_VIEW_DISPLAY_NORMAL);
VisualServer::get_singleton()->instance_geometry_set_flag(origin_instance,VS::INSTANCE_FLAG_VISIBLE,true);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), true);
for(int i=0;i<3;++i) {
if (grid_enable[i]) {
VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,true);
grid_visible[i]=true;
}
}
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID), true );
}
SpatialEditor::SpatialEditor(EditorNode *p_editor) {
@ -3501,7 +3541,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
settings_zfar->set_anchor( MARGIN_RIGHT, ANCHOR_END );
settings_zfar->set_begin( Point2(15,102) );
settings_zfar->set_end( Point2(15,115) );
settings_zfar->set_text(EDITOR_DEF("3d_editor/default_z_far",500.0));
settings_zfar->set_text(EDITOR_DEF("3d_editor/default_z_far",1500.0));
settings_dialog->add_child(settings_zfar);
//settings_dialog->get_cancel()->hide();

View File

@ -222,6 +222,7 @@ public:
void set_can_preview(Camera* p_preview);
void set_state(const Dictionary& p_state);
Dictionary get_state() const;
void reset();
@ -477,6 +478,7 @@ public:
Camera *get_camera() { return NULL; }
void edit(Spatial *p_spatial);
void clear();
SpatialEditor(EditorNode *p_editor);
~SpatialEditor();
};
@ -502,6 +504,7 @@ public:
virtual Dictionary get_state() const;
virtual void set_state(const Dictionary& p_state);
virtual void clear() { spatial_editor->clear(); }
SpatialEditorPlugin(EditorNode *p_node);

View File

@ -94,7 +94,6 @@ class SpatialGizmoTool : public SpatialEditorGizmo {
Vector<Instance> instances;
Spatial *spatial_node;
protected:
void clear();
void add_lines(const Vector<Vector3> &p_lines,const Ref<Material>& p_material,bool p_billboard=false);
void add_mesh(const Ref<Mesh>& p_mesh,bool p_billboard=false,const RID& p_skeleton=RID());
void add_collision_segments(const Vector<Vector3> &p_lines);
@ -110,6 +109,7 @@ public:
virtual bool intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum);
virtual bool intersect_ray(const Camera *p_camera,const Point2& p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle=NULL,bool p_sec_first=false);
void clear();
void create();
void transform();
//void redraw();