mirror of
https://github.com/godotengine/godot.git
synced 2025-10-27 19:54:27 +00:00
Begining of GLES3 renderer:
-Most 2D drawing is implemented -Missing shaders -Missing all 3D -Editor needs to be set on update always to be used, otherwise it does not refresh -Large parts of editor not working
This commit is contained in:
parent
78d97b060a
commit
22d83bc9f6
211 changed files with 15188 additions and 14195 deletions
|
|
@ -274,7 +274,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b
|
|||
Vector3 ray=_get_ray(p_pos);
|
||||
Vector3 pos=_get_ray_pos(p_pos);
|
||||
|
||||
Vector<RID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() );
|
||||
Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() );
|
||||
Set<Ref<SpatialEditorGizmo> > found_gizmos;
|
||||
|
||||
//uint32_t closest=0;
|
||||
|
|
@ -286,8 +286,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b
|
|||
|
||||
for (int i=0;i<instances.size();i++) {
|
||||
|
||||
uint32_t id=VisualServer::get_singleton()->instance_get_object_instance_ID(instances[i]);
|
||||
Object *obj=ObjectDB::get_instance(id);
|
||||
Object *obj=ObjectDB::get_instance(instances[i]);
|
||||
if (!obj)
|
||||
continue;
|
||||
|
||||
|
|
@ -405,15 +404,15 @@ void SpatialEditorViewport::_find_items_at_pos(const Point2& p_pos,bool &r_inclu
|
|||
Vector3 ray=_get_ray(p_pos);
|
||||
Vector3 pos=_get_ray_pos(p_pos);
|
||||
|
||||
Vector<RID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() );
|
||||
Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() );
|
||||
Set<Ref<SpatialEditorGizmo> > found_gizmos;
|
||||
|
||||
r_includes_current=false;
|
||||
|
||||
for (int i=0;i<instances.size();i++) {
|
||||
|
||||
uint32_t id=VisualServer::get_singleton()->instance_get_object_instance_ID(instances[i]);
|
||||
Object *obj=ObjectDB::get_instance(id);
|
||||
Object *obj=ObjectDB::get_instance(instances[i]);
|
||||
|
||||
if (!obj)
|
||||
continue;
|
||||
|
||||
|
|
@ -534,14 +533,12 @@ void SpatialEditorViewport::_select_region() {
|
|||
|
||||
frustum.push_back( far );
|
||||
|
||||
Vector<RID> instances=VisualServer::get_singleton()->instances_cull_convex(frustum,get_tree()->get_root()->get_world()->get_scenario());
|
||||
Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_convex(frustum,get_tree()->get_root()->get_world()->get_scenario());
|
||||
|
||||
|
||||
for (int i=0;i<instances.size();i++) {
|
||||
|
||||
uint32_t id=VisualServer::get_singleton()->instance_get_object_instance_ID(instances[i]);
|
||||
|
||||
Object *obj=ObjectDB::get_instance(id);
|
||||
Object *obj=ObjectDB::get_instance(instances[i]);
|
||||
if (!obj)
|
||||
continue;
|
||||
Spatial *sp = obj->cast_to<Spatial>();
|
||||
|
|
@ -877,7 +874,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
|
|||
|
||||
if (b.mod.control) {
|
||||
|
||||
Vector<RID> instances=VisualServer::get_singleton()->instances_cull_ray(ray_origin,ray_dir,get_tree()->get_root()->get_world()->get_scenario() );
|
||||
Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(ray_origin,ray_dir,get_tree()->get_root()->get_world()->get_scenario() );
|
||||
|
||||
Plane p(ray_origin,_get_camera_normal());
|
||||
|
||||
|
|
@ -886,8 +883,9 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
|
|||
|
||||
for (int i=0;i<instances.size();i++) {
|
||||
|
||||
uint32_t id=VisualServer::get_singleton()->instance_get_object_instance_ID(instances[i]);
|
||||
Object *obj=ObjectDB::get_instance(id);
|
||||
|
||||
Object *obj=ObjectDB::get_instance(instances[i]);
|
||||
|
||||
if (!obj)
|
||||
continue;
|
||||
|
||||
|
|
@ -2061,9 +2059,9 @@ void SpatialEditorViewport::_menu_option(int p_option) {
|
|||
bool current = view_menu->get_popup()->is_item_checked( idx );
|
||||
current=!current;
|
||||
if (current)
|
||||
camera->set_visible_layers( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) );
|
||||
camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) );
|
||||
else
|
||||
camera->set_visible_layers( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_GRID_LAYER) );
|
||||
camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_GRID_LAYER) );
|
||||
view_menu->get_popup()->set_item_checked( idx, current );
|
||||
|
||||
} break;
|
||||
|
|
@ -2361,7 +2359,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
|
|||
surface->set_area_as_parent_rect();
|
||||
camera = memnew(Camera);
|
||||
camera->set_disable_gizmo(true);
|
||||
camera->set_visible_layers( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+p_index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) );
|
||||
camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+p_index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) );
|
||||
//camera->set_environment(SpatialEditor::get_singleton()->get_viewport_environment());
|
||||
viewport->add_child(camera);
|
||||
camera->make_current();
|
||||
|
|
@ -2370,7 +2368,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
|
|||
view_menu = memnew( MenuButton );
|
||||
surface->add_child(view_menu);
|
||||
view_menu->set_pos( Point2(4,4));
|
||||
view_menu->set_self_opacity(0.5);
|
||||
view_menu->set_self_modulate(Color(1,1,1,0.5));
|
||||
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
|
||||
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
|
||||
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT);
|
||||
|
|
@ -2550,10 +2548,10 @@ void SpatialEditor::_generate_selection_box() {
|
|||
}
|
||||
|
||||
Ref<FixedMaterial> mat = memnew( FixedMaterial );
|
||||
mat->set_flag(Material::FLAG_UNSHADED,true);
|
||||
/*mat->set_flag(Material::FLAG_UNSHADED,true);
|
||||
mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1));
|
||||
mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
|
||||
mat->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true);
|
||||
mat->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true);*/
|
||||
st->set_material(mat);
|
||||
selection_box = st->commit();
|
||||
}
|
||||
|
|
@ -2685,14 +2683,14 @@ void SpatialEditor::set_state(const Dictionary& p_state) {
|
|||
}
|
||||
if (d.has("ambient_light_color")) {
|
||||
settings_ambient_color->set_color(d["ambient_light_color"]);
|
||||
viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,d["ambient_light_color"]);
|
||||
//viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,d["ambient_light_color"]);
|
||||
}
|
||||
|
||||
if (d.has("default_srgb")) {
|
||||
bool use = d["default_srgb"];
|
||||
|
||||
viewport_environment->set_enable_fx(Environment::FX_SRGB,use);
|
||||
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB), use );
|
||||
//viewport_environment->set_enable_fx(Environment::FX_SRGB,use);
|
||||
//view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB), use );
|
||||
}
|
||||
if (d.has("show_grid")) {
|
||||
bool use = d["show_grid"];
|
||||
|
|
@ -2892,9 +2890,9 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
|
|||
bool is_checked = view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(p_option) );
|
||||
|
||||
if (is_checked) {
|
||||
viewport_environment->set_enable_fx(Environment::FX_SRGB,false);
|
||||
//viewport_environment->set_enable_fx(Environment::FX_SRGB,false);
|
||||
} else {
|
||||
viewport_environment->set_enable_fx(Environment::FX_SRGB,true);
|
||||
//viewport_environment->set_enable_fx(Environment::FX_SRGB,true);
|
||||
}
|
||||
|
||||
is_checked = ! is_checked;
|
||||
|
|
@ -3140,11 +3138,11 @@ void SpatialEditor::_init_indicators() {
|
|||
|
||||
{
|
||||
|
||||
indicator_mat = VisualServer::get_singleton()->fixed_material_create();
|
||||
VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true );
|
||||
indicator_mat = VisualServer::get_singleton()->material_create();
|
||||
/*VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true );
|
||||
VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_ONTOP, false );
|
||||
VisualServer::get_singleton()->fixed_material_set_flag(indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true);
|
||||
VisualServer::get_singleton()->fixed_material_set_flag(indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true);
|
||||
VisualServer::get_singleton()->fixed_material_set_flag(indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true);*/
|
||||
|
||||
DVector<Color> grid_colors[3];
|
||||
DVector<Vector3> grid_points[3];
|
||||
|
|
@ -3186,7 +3184,7 @@ void SpatialEditor::_init_indicators() {
|
|||
d.resize(VS::ARRAY_MAX);
|
||||
d[VisualServer::ARRAY_VERTEX]=grid_points[i];
|
||||
d[VisualServer::ARRAY_COLOR]=grid_colors[i];
|
||||
VisualServer::get_singleton()->mesh_add_surface(grid[i],VisualServer::PRIMITIVE_LINES,d);
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i],VisualServer::PRIMITIVE_LINES,d);
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat);
|
||||
grid_instance[i] = VisualServer::get_singleton()->instance_create2(grid[i],get_tree()->get_root()->get_world()->get_scenario());
|
||||
|
||||
|
|
@ -3205,7 +3203,7 @@ void SpatialEditor::_init_indicators() {
|
|||
d[VisualServer::ARRAY_VERTEX]=origin_points;
|
||||
d[VisualServer::ARRAY_COLOR]=origin_colors;
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface(origin,VisualServer::PRIMITIVE_LINES,d);
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(origin,VisualServer::PRIMITIVE_LINES,d);
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat);
|
||||
|
||||
|
||||
|
|
@ -3237,16 +3235,16 @@ void SpatialEditor::_init_indicators() {
|
|||
cursor_points.push_back(Vector3(0,-cs,0));
|
||||
cursor_points.push_back(Vector3(0,0,+cs));
|
||||
cursor_points.push_back(Vector3(0,0,-cs));
|
||||
cursor_material=VisualServer::get_singleton()->fixed_material_create();
|
||||
VisualServer::get_singleton()->fixed_material_set_param(cursor_material,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0,1,1));
|
||||
cursor_material=VisualServer::get_singleton()->material_create();
|
||||
/*VisualServer::get_singleton()->fixed_material_set_param(cursor_material,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0,1,1));
|
||||
VisualServer::get_singleton()->material_set_flag( cursor_material, VisualServer::MATERIAL_FLAG_UNSHADED, true );
|
||||
VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true);
|
||||
VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true);
|
||||
VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true);*/
|
||||
|
||||
Array d;
|
||||
d.resize(VS::ARRAY_MAX);
|
||||
d[VS::ARRAY_VERTEX]=cursor_points;
|
||||
VisualServer::get_singleton()->mesh_add_surface(cursor_mesh,VS::PRIMITIVE_LINES,d);
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(cursor_mesh,VS::PRIMITIVE_LINES,d);
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh,0,cursor_material);
|
||||
|
||||
cursor_instance = VisualServer::get_singleton()->instance_create2(cursor_mesh,get_tree()->get_root()->get_world()->get_scenario());
|
||||
|
|
@ -3266,10 +3264,10 @@ void SpatialEditor::_init_indicators() {
|
|||
float gizmo_alph = EditorSettings::get_singleton()->get("3d_editor/manipulator_gizmo_opacity");
|
||||
|
||||
gizmo_hl = Ref<FixedMaterial>( memnew( FixedMaterial ) );
|
||||
gizmo_hl->set_flag(Material::FLAG_UNSHADED, true);
|
||||
/* gizmo_hl->set_flag(Material::FLAG_UNSHADED, true);
|
||||
gizmo_hl->set_flag(Material::FLAG_ONTOP, true);
|
||||
gizmo_hl->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
|
||||
gizmo_hl->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,gizmo_alph+0.2f));
|
||||
gizmo_hl->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,gizmo_alph+0.2f));*/
|
||||
|
||||
for(int i=0;i<3;i++) {
|
||||
|
||||
|
|
@ -3278,13 +3276,13 @@ void SpatialEditor::_init_indicators() {
|
|||
|
||||
|
||||
Ref<FixedMaterial> mat = memnew( FixedMaterial );
|
||||
mat->set_flag(Material::FLAG_UNSHADED, true);
|
||||
/* mat->set_flag(Material::FLAG_UNSHADED, true);
|
||||
mat->set_flag(Material::FLAG_ONTOP, true);
|
||||
mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
|
||||
Color col;
|
||||
col[i]=1.0;
|
||||
col.a= gizmo_alph;
|
||||
mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,col);
|
||||
mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,col);*/
|
||||
gizmo_color[i]=mat;
|
||||
|
||||
|
||||
|
|
@ -3548,7 +3546,7 @@ void SpatialEditor::_notification(int p_what) {
|
|||
|
||||
if (p_what==NOTIFICATION_ENTER_TREE) {
|
||||
|
||||
gizmos = memnew( SpatialEditorGizmos );
|
||||
//gizmos = memnew( SpatialEditorGizmos );
|
||||
_init_indicators();
|
||||
_update_default_light_angle();
|
||||
}
|
||||
|
|
@ -3556,7 +3554,7 @@ void SpatialEditor::_notification(int p_what) {
|
|||
if (p_what==NOTIFICATION_EXIT_TREE) {
|
||||
|
||||
_finish_indicators();
|
||||
memdelete( gizmos );
|
||||
// memdelete( gizmos );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -3602,7 +3600,7 @@ void SpatialEditor::_request_gizmo(Object* p_obj) {
|
|||
}
|
||||
|
||||
if (!seg.is_valid()) {
|
||||
seg = gizmos->get_gizmo(sp);
|
||||
// seg = gizmos->get_gizmo(sp);
|
||||
}
|
||||
|
||||
if (seg.is_valid()) {
|
||||
|
|
@ -3724,7 +3722,7 @@ void SpatialEditor::clear() {
|
|||
settings_default_light_rot_x=Math_PI*0.3;
|
||||
settings_default_light_rot_y=Math_PI*0.2;
|
||||
|
||||
viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15));
|
||||
//viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15));
|
||||
settings_ambient_color->set_color(Color(0.15,0.15,0.15));
|
||||
if (!light_instance.is_valid())
|
||||
_menu_item_pressed(MENU_VIEW_USE_DEFAULT_LIGHT);
|
||||
|
|
@ -3737,7 +3735,7 @@ void SpatialEditor::clear() {
|
|||
|
||||
void SpatialEditor::_update_ambient_light_color(const Color& p_color) {
|
||||
|
||||
viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,settings_ambient_color->get_color());
|
||||
// viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,settings_ambient_color->get_color());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -4006,8 +4004,8 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
|||
settings_vbc->add_margin_child(TTR("Ambient Light Color:"),settings_ambient_color);
|
||||
settings_ambient_color->connect("color_changed",this,"_update_ambient_light_color");
|
||||
|
||||
viewport_environment->set_enable_fx(Environment::FX_AMBIENT_LIGHT,true);
|
||||
viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15));
|
||||
// viewport_environment->set_enable_fx(Environment::FX_AMBIENT_LIGHT,true);
|
||||
// viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15));
|
||||
settings_ambient_color->set_color(Color(0.15,0.15,0.15));
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue