114 lines
3.3 KiB
C++
114 lines
3.3 KiB
C++
#include "mesher.h"
|
|
CompoundTransvoxel::CompoundTransvoxel() : VoxelMesherTransvoxel()
|
|
{
|
|
}
|
|
|
|
CompoundTransvoxel::~CompoundTransvoxel()
|
|
{
|
|
}
|
|
|
|
void CompoundTransvoxel::build(VoxelMesher::Output &output, const VoxelMesher::Input &input)
|
|
{
|
|
VoxelMesherTransvoxel::build(output, input);
|
|
}
|
|
|
|
Ref<Resource> CompoundTransvoxel::duplicate(bool p_subresources) const
|
|
{
|
|
return VoxelMesherTransvoxel::duplicate(p_subresources);
|
|
}
|
|
|
|
int CompoundTransvoxel::get_used_channels_mask() const
|
|
{
|
|
return VoxelMesherTransvoxel::get_used_channels_mask();
|
|
}
|
|
|
|
void CompoundTransvoxelInspector::open_scene(Object *button)
|
|
{
|
|
CompoundTransvoxel *obj = Object::cast_to<CompoundTransvoxel>(button->get_meta("what"));
|
|
fd->set_meta("what", obj);
|
|
fd->popup_centered_ratio();
|
|
}
|
|
|
|
CompoundTransvoxelInspector::CompoundTransvoxelInspector(): EditorInspectorPlugin()
|
|
{
|
|
}
|
|
|
|
void CompoundTransvoxel::_bind_methods()
|
|
{
|
|
}
|
|
void CompoundTransvoxelInspector::_bind_methods()
|
|
{
|
|
ClassDB::bind_method(D_METHOD("open_scene", "button"), &CompoundTransvoxelInspector::open_scene);
|
|
}
|
|
bool CompoundTransvoxelInspector::can_handle(Object *p_object)
|
|
{
|
|
return Object::cast_to<CompoundTransvoxel>(p_object) != NULL;
|
|
}
|
|
void CompoundTransvoxelInspector::scenes_selected(const PoolVector<String> &p_paths)
|
|
{
|
|
struct CompoundTransvoxel::place_item it;
|
|
for (int i = 0; i < p_paths.size(); i++) {
|
|
Ref<PackedScene> t = Ref<PackedScene>(ResourceLoader::load(p_paths[i]));
|
|
ERR_CONTINUE_MSG(!t.is_valid(), "'" + p_paths[i] + "' is not a valid scene.");
|
|
it.scene = t;
|
|
}
|
|
}
|
|
void CompoundTransvoxelInspector::parse_begin(Object *p_object)
|
|
{
|
|
int i;
|
|
CompoundTransvoxel *obj = Object::cast_to<CompoundTransvoxel>(p_object);
|
|
if (!obj)
|
|
return;
|
|
VBoxContainer *control = memnew(VBoxContainer);
|
|
fd = memnew(EditorFileDialog);
|
|
fd->set_access(EditorFileDialog::ACCESS_RESOURCES);
|
|
fd->set_mode(EditorFileDialog::MODE_OPEN_FILE);
|
|
fd->set_resizable(true);
|
|
List<String> extensions;
|
|
ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions);
|
|
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
|
|
fd->add_filter("*." + E->get() + " ; " + E->get().to_upper());
|
|
}
|
|
fd->connect("files_selected", this, "scenes_selected");
|
|
|
|
control->add_child(fd);
|
|
for (i = 0; i < obj->items.size(); i++) {
|
|
HBoxContainer *vcontrol = memnew(HBoxContainer);
|
|
Button *open_scene = memnew(Button);
|
|
open_scene->set_text("Select scene...");
|
|
open_scene->connect("pressed", this, "open_scene", Node::make_binds(open_scene));
|
|
open_scene->set_meta("what", &obj->items[i]);
|
|
vcontrol->add_child(open_scene);
|
|
Label *l1 = memnew(Label);
|
|
l1->set_text("scene path: ");
|
|
vcontrol->add_child(l1);
|
|
/* full instance */
|
|
Label *l2 = memnew(Label);
|
|
l2->set_text("full instance: ");
|
|
vcontrol->add_child(l2);
|
|
CheckBox *cb1 = memnew(CheckBox);
|
|
vcontrol->add_child(cb1);
|
|
/* use collision */
|
|
Label *l3 = memnew(Label);
|
|
l3->set_text("use collision: ");
|
|
vcontrol->add_child(l3);
|
|
CheckBox *cb2 = memnew(CheckBox);
|
|
vcontrol->add_child(cb2);
|
|
/* priority */
|
|
Label *l4 = memnew(Label);
|
|
l4->set_text("priority: ");
|
|
vcontrol->add_child(l4);
|
|
#if 0
|
|
SpinBox *sb1 = memnew(SpinBox);
|
|
vcontrol->add_child(sb1);
|
|
#endif
|
|
control->add_child(vcontrol);
|
|
}
|
|
Button *addbutton = memnew(Button);
|
|
addbutton->set_text("+");
|
|
control->add_child(addbutton);
|
|
add_custom_control(control);
|
|
}
|
|
|
|
|