Merge pull request #21747 from akien-mga/split-particlesmaterial
Move ParticlesMaterial code to its own resource file
This commit is contained in:
commit
e8a6c5844a
22 changed files with 1620 additions and 2001 deletions
|
@ -29,6 +29,7 @@
|
|||
/*************************************************************************/
|
||||
|
||||
#include "cpu_particles_editor_plugin.h"
|
||||
|
||||
#include "editor/plugins/spatial_editor_plugin.h"
|
||||
|
||||
void CPUParticlesEditor::_node_removed(Node *p_node) {
|
||||
|
|
|
@ -28,397 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
// FIXME: Disabled as (according to reduz) users were complaining that it gets in the way
|
||||
// Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored.
|
||||
|
||||
#include "material_editor_plugin.h"
|
||||
#include "scene/3d/particles.h"
|
||||
|
||||
#if 0
|
||||
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
void MaterialEditor::_gui_input(InputEvent p_event) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MaterialEditor::_notification(int p_what) {
|
||||
|
||||
if (p_what==NOTIFICATION_PHYSICS_PROCESS) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (p_what==NOTIFICATION_READY) {
|
||||
|
||||
//get_scene()->connect("node_removed",this,"_node_removed");
|
||||
|
||||
if (first_enter) {
|
||||
//it's in propertyeditor so.. could be moved around
|
||||
|
||||
light_1_switch->set_normal_texture(get_icon("MaterialPreviewLight1","EditorIcons"));
|
||||
light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off","EditorIcons"));
|
||||
light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2","EditorIcons"));
|
||||
light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off","EditorIcons"));
|
||||
|
||||
sphere_switch->set_normal_texture(get_icon("MaterialPreviewSphereOff","EditorIcons"));
|
||||
sphere_switch->set_pressed_texture(get_icon("MaterialPreviewSphere","EditorIcons"));
|
||||
box_switch->set_normal_texture(get_icon("MaterialPreviewCubeOff","EditorIcons"));
|
||||
box_switch->set_pressed_texture(get_icon("MaterialPreviewCube","EditorIcons"));
|
||||
|
||||
first_enter=false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (p_what==NOTIFICATION_DRAW) {
|
||||
|
||||
|
||||
Ref<Texture> checkerboard = get_icon("Checkerboard","EditorIcons");
|
||||
Size2 size = get_size();
|
||||
|
||||
draw_texture_rect(checkerboard,Rect2(Point2(),size),true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MaterialEditor::edit(Ref<Material> p_material) {
|
||||
|
||||
material=p_material;
|
||||
|
||||
if (!material.is_null()) {
|
||||
sphere_mesh->surface_set_material(0,material);
|
||||
box_mesh->surface_set_material(0,material);
|
||||
} else {
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MaterialEditor::_button_pressed(Node* p_button) {
|
||||
|
||||
if (p_button==light_1_switch) {
|
||||
light1->set_enabled(!light_1_switch->is_pressed());
|
||||
}
|
||||
|
||||
if (p_button==light_2_switch) {
|
||||
light2->set_enabled(!light_2_switch->is_pressed());
|
||||
}
|
||||
|
||||
if (p_button==box_switch) {
|
||||
box_instance->show();
|
||||
sphere_instance->hide();
|
||||
box_switch->set_pressed(true);
|
||||
sphere_switch->set_pressed(false);
|
||||
}
|
||||
|
||||
if (p_button==sphere_switch) {
|
||||
box_instance->hide();
|
||||
sphere_instance->show();
|
||||
box_switch->set_pressed(false);
|
||||
sphere_switch->set_pressed(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MaterialEditor::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_gui_input"),&MaterialEditor::_gui_input);
|
||||
ClassDB::bind_method(D_METHOD("_button_pressed"),&MaterialEditor::_button_pressed);
|
||||
|
||||
}
|
||||
|
||||
MaterialEditor::MaterialEditor() {
|
||||
|
||||
viewport = memnew( Viewport );
|
||||
Ref<World> world;
|
||||
world.instance();
|
||||
viewport->set_world(world); //use own world
|
||||
add_child(viewport);
|
||||
viewport->set_disable_input(true);
|
||||
|
||||
camera = memnew( Camera );
|
||||
camera->set_transform(Transform(Matrix3(),Vector3(0,0,3)));
|
||||
camera->set_perspective(45,0.1,10);
|
||||
viewport->add_child(camera);
|
||||
|
||||
light1 = memnew( DirectionalLight );
|
||||
light1->set_transform(Transform().looking_at(Vector3(-1,-1,-1),Vector3(0,1,0)));
|
||||
viewport->add_child(light1);
|
||||
|
||||
light2 = memnew( DirectionalLight );
|
||||
light2->set_transform(Transform().looking_at(Vector3(0,1,0),Vector3(0,0,1)));
|
||||
light2->set_color(Light::COLOR_DIFFUSE,Color(0.7,0.7,0.7));
|
||||
light2->set_color(Light::COLOR_SPECULAR,Color(0.7,0.7,0.7));
|
||||
viewport->add_child(light2);
|
||||
|
||||
sphere_instance = memnew( MeshInstance );
|
||||
viewport->add_child(sphere_instance);
|
||||
|
||||
box_instance = memnew( MeshInstance );
|
||||
viewport->add_child(box_instance);
|
||||
|
||||
Transform box_xform;
|
||||
box_xform.basis.rotate(Vector3(1,0,0),Math::deg2rad(25));
|
||||
box_xform.basis = box_xform.basis * Matrix3().rotated(Vector3(0,1,0),Math::deg2rad(25));
|
||||
box_xform.basis.scale(Vector3(0.8,0.8,0.8));
|
||||
box_instance->set_transform(box_xform);
|
||||
|
||||
{
|
||||
|
||||
sphere_mesh.instance();
|
||||
|
||||
|
||||
int lats=32;
|
||||
int lons=32;
|
||||
float radius=1.0;
|
||||
|
||||
PoolVector<Vector3> vertices;
|
||||
PoolVector<Vector3> normals;
|
||||
PoolVector<Vector2> uvs;
|
||||
PoolVector<float> tangents;
|
||||
Matrix3 tt = Matrix3(Vector3(0,1,0),Math_PI*0.5);
|
||||
|
||||
for(int i = 1; i <= lats; i++) {
|
||||
double lat0 = Math_PI * (-0.5 + (double) (i - 1) / lats);
|
||||
double z0 = Math::sin(lat0);
|
||||
double zr0 = Math::cos(lat0);
|
||||
|
||||
double lat1 = Math_PI * (-0.5 + (double) i / lats);
|
||||
double z1 = Math::sin(lat1);
|
||||
double zr1 = Math::cos(lat1);
|
||||
|
||||
for(int j = lons; j >= 1; j--) {
|
||||
|
||||
double lng0 = 2 * Math_PI * (double) (j - 1) / lons;
|
||||
double x0 = Math::cos(lng0);
|
||||
double y0 = Math::sin(lng0);
|
||||
|
||||
double lng1 = 2 * Math_PI * (double) (j) / lons;
|
||||
double x1 = Math::cos(lng1);
|
||||
double y1 = Math::sin(lng1);
|
||||
|
||||
|
||||
Vector3 v[4]={
|
||||
Vector3(x1 * zr0, z0, y1 *zr0),
|
||||
Vector3(x1 * zr1, z1, y1 *zr1),
|
||||
Vector3(x0 * zr1, z1, y0 *zr1),
|
||||
Vector3(x0 * zr0, z0, y0 *zr0)
|
||||
};
|
||||
|
||||
#define ADD_POINT(m_idx) \
|
||||
normals.push_back(v[m_idx]); \
|
||||
vertices.push_back(v[m_idx] * radius); \
|
||||
{ \
|
||||
Vector2 uv(Math::atan2(v[m_idx].x, v[m_idx].z), Math::atan2(-v[m_idx].y, v[m_idx].z)); \
|
||||
uv /= Math_PI; \
|
||||
uv *= 4.0; \
|
||||
uv = uv * 0.5 + Vector2(0.5, 0.5); \
|
||||
uvs.push_back(uv); \
|
||||
} \
|
||||
{ \
|
||||
Vector3 t = tt.xform(v[m_idx]); \
|
||||
tangents.push_back(t.x); \
|
||||
tangents.push_back(t.y); \
|
||||
tangents.push_back(t.z); \
|
||||
tangents.push_back(1.0); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
ADD_POINT(0);
|
||||
ADD_POINT(1);
|
||||
ADD_POINT(2);
|
||||
|
||||
ADD_POINT(2);
|
||||
ADD_POINT(3);
|
||||
ADD_POINT(0);
|
||||
}
|
||||
}
|
||||
|
||||
Array arr;
|
||||
arr.resize(VS::ARRAY_MAX);
|
||||
arr[VS::ARRAY_VERTEX]=vertices;
|
||||
arr[VS::ARRAY_NORMAL]=normals;
|
||||
arr[VS::ARRAY_TANGENT]=tangents;
|
||||
arr[VS::ARRAY_TEX_UV]=uvs;
|
||||
|
||||
sphere_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr);
|
||||
|
||||
sphere_instance->set_mesh(sphere_mesh);
|
||||
|
||||
}
|
||||
{
|
||||
|
||||
|
||||
box_mesh.instance();
|
||||
|
||||
PoolVector<Vector3> vertices;
|
||||
PoolVector<Vector3> normals;
|
||||
PoolVector<float> tangents;
|
||||
PoolVector<Vector3> uvs;
|
||||
|
||||
int vtx_idx=0;
|
||||
#define ADD_VTX(m_idx) \
|
||||
; \
|
||||
vertices.push_back(face_points[m_idx]); \
|
||||
normals.push_back(normal_points[m_idx]); \
|
||||
tangents.push_back(normal_points[m_idx][1]); \
|
||||
tangents.push_back(normal_points[m_idx][2]); \
|
||||
tangents.push_back(normal_points[m_idx][0]); \
|
||||
tangents.push_back(1.0); \
|
||||
uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0)); \
|
||||
vtx_idx++;\
|
||||
|
||||
for (int i=0;i<6;i++) {
|
||||
|
||||
|
||||
Vector3 face_points[4];
|
||||
Vector3 normal_points[4];
|
||||
float uv_points[8]={0,0,0,1,1,1,1,0};
|
||||
|
||||
for (int j=0;j<4;j++) {
|
||||
|
||||
float v[3];
|
||||
v[0]=1.0;
|
||||
v[1]=1-2*((j>>1)&1);
|
||||
v[2]=v[1]*(1-2*(j&1));
|
||||
|
||||
for (int k=0;k<3;k++) {
|
||||
|
||||
if (i<3)
|
||||
face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
|
||||
else
|
||||
face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
|
||||
}
|
||||
normal_points[j]=Vector3();
|
||||
normal_points[j][i%3]=(i>=3?-1:1);
|
||||
}
|
||||
|
||||
//tri 1
|
||||
ADD_VTX(0);
|
||||
ADD_VTX(1);
|
||||
ADD_VTX(2);
|
||||
//tri 2
|
||||
ADD_VTX(2);
|
||||
ADD_VTX(3);
|
||||
ADD_VTX(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Array d;
|
||||
d.resize(VS::ARRAY_MAX);
|
||||
d[VisualServer::ARRAY_NORMAL]= normals ;
|
||||
d[VisualServer::ARRAY_TANGENT]= tangents ;
|
||||
d[VisualServer::ARRAY_TEX_UV]= uvs ;
|
||||
d[VisualServer::ARRAY_VERTEX]= vertices ;
|
||||
|
||||
PoolVector<int> indices;
|
||||
indices.resize(vertices.size());
|
||||
for(int i=0;i<vertices.size();i++)
|
||||
indices.set(i,i);
|
||||
d[VisualServer::ARRAY_INDEX]=indices;
|
||||
|
||||
box_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,d);
|
||||
box_instance->set_mesh(box_mesh);
|
||||
box_instance->hide();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
set_custom_minimum_size(Size2(1,150)*EDSCALE);
|
||||
|
||||
HBoxContainer *hb = memnew( HBoxContainer );
|
||||
add_child(hb);
|
||||
hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);
|
||||
|
||||
VBoxContainer *vb_shape = memnew( VBoxContainer );
|
||||
hb->add_child(vb_shape);
|
||||
|
||||
sphere_switch = memnew( TextureButton );
|
||||
sphere_switch->set_toggle_mode(true);
|
||||
sphere_switch->set_pressed(true);
|
||||
vb_shape->add_child(sphere_switch);
|
||||
sphere_switch->connect("pressed",this,"_button_pressed",varray(sphere_switch));
|
||||
|
||||
box_switch = memnew( TextureButton );
|
||||
box_switch->set_toggle_mode(true);
|
||||
box_switch->set_pressed(false);
|
||||
vb_shape->add_child(box_switch);
|
||||
box_switch->connect("pressed",this,"_button_pressed",varray(box_switch));
|
||||
|
||||
hb->add_spacer();
|
||||
|
||||
VBoxContainer *vb_light = memnew( VBoxContainer );
|
||||
hb->add_child(vb_light);
|
||||
|
||||
light_1_switch = memnew( TextureButton );
|
||||
light_1_switch->set_toggle_mode(true);
|
||||
vb_light->add_child(light_1_switch);
|
||||
light_1_switch->connect("pressed",this,"_button_pressed",varray(light_1_switch));
|
||||
|
||||
light_2_switch = memnew( TextureButton );
|
||||
light_2_switch->set_toggle_mode(true);
|
||||
vb_light->add_child(light_2_switch);
|
||||
light_2_switch->connect("pressed",this,"_button_pressed",varray(light_2_switch));
|
||||
|
||||
first_enter=true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MaterialEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
Material * s = Object::cast_to<Material>(p_object);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
material_editor->edit(Ref<Material>(s));
|
||||
}
|
||||
|
||||
bool MaterialEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
return p_object->is_type("Material");
|
||||
}
|
||||
|
||||
void MaterialEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
material_editor->show();
|
||||
//material_editor->set_process(true);
|
||||
} else {
|
||||
|
||||
material_editor->hide();
|
||||
//material_editor->set_process(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor=p_node;
|
||||
material_editor = memnew( MaterialEditor );
|
||||
add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,material_editor);
|
||||
material_editor->hide();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
MaterialEditorPlugin::~MaterialEditorPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "scene/resources/particles_material.h"
|
||||
|
||||
String SpatialMaterialConversionPlugin::converts_to() const {
|
||||
|
||||
|
|
|
@ -32,77 +32,6 @@
|
|||
#define MATERIAL_EDITOR_PLUGIN_H
|
||||
|
||||
#include "editor/property_editor.h"
|
||||
// FIXME: Disabled as (according to reduz) users were complaining that it gets in the way
|
||||
// Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored.
|
||||
#if 0
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/3d/light.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/resources/material.h"
|
||||
|
||||
class MaterialEditor : public Control {
|
||||
|
||||
GDCLASS(MaterialEditor, Control);
|
||||
|
||||
|
||||
Viewport *viewport;
|
||||
MeshInstance *sphere_instance;
|
||||
MeshInstance *box_instance;
|
||||
DirectionalLight *light1;
|
||||
DirectionalLight *light2;
|
||||
Camera *camera;
|
||||
|
||||
Ref<Mesh> sphere_mesh;
|
||||
Ref<Mesh> box_mesh;
|
||||
|
||||
TextureButton *sphere_switch;
|
||||
TextureButton *box_switch;
|
||||
|
||||
TextureButton *light_1_switch;
|
||||
TextureButton *light_2_switch;
|
||||
|
||||
|
||||
Ref<Material> material;
|
||||
|
||||
|
||||
void _button_pressed(Node* p_button);
|
||||
bool first_enter;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
void _gui_input(InputEvent p_event);
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
void edit(Ref<Material> p_material);
|
||||
MaterialEditor();
|
||||
};
|
||||
|
||||
|
||||
class MaterialEditorPlugin : public EditorPlugin {
|
||||
|
||||
GDCLASS( MaterialEditorPlugin, EditorPlugin );
|
||||
|
||||
MaterialEditor *material_editor;
|
||||
EditorNode *editor;
|
||||
|
||||
public:
|
||||
|
||||
virtual String get_name() const { return "Material"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
virtual void edit(Object *p_node);
|
||||
virtual bool handles(Object *p_node) const;
|
||||
virtual void make_visible(bool p_visible);
|
||||
|
||||
MaterialEditorPlugin(EditorNode *p_node);
|
||||
~MaterialEditorPlugin();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin {
|
||||
GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin)
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
|
||||
#include "canvas_item_editor_plugin.h"
|
||||
#include "io/image_loader.h"
|
||||
#include "scene/3d/particles.h"
|
||||
#include "scene/gui/separator.h"
|
||||
#include "scene/resources/particles_material.h"
|
||||
|
||||
void Particles2DEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "scene/2d/collision_polygon_2d.h"
|
||||
|
||||
#include "scene/2d/particles_2d.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/file_dialog.h"
|
||||
|
|
|
@ -29,9 +29,12 @@
|
|||
/*************************************************************************/
|
||||
|
||||
#include "particles_editor_plugin.h"
|
||||
|
||||
#include "editor/plugins/spatial_editor_plugin.h"
|
||||
#include "io/resource_loader.h"
|
||||
#include "scene/3d/cpu_particles.h"
|
||||
#include "scene/resources/particles_material.h"
|
||||
|
||||
bool ParticlesEditorBase::_generate(PoolVector<Vector3> &points, PoolVector<Vector3> &normals) {
|
||||
|
||||
bool use_normals = emission_fill->get_selected() == 1;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
class ParticlesEditorBase : public Control {
|
||||
|
||||
GDCLASS(ParticlesEditorBase, Control)
|
||||
|
||||
protected:
|
||||
Spatial *base_node;
|
||||
Panel *panel;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "path_editor_plugin.h"
|
||||
|
||||
#include "os/keyboard.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "scene/resources/curve.h"
|
||||
#include "spatial_editor_plugin.h"
|
||||
|
||||
|
|
|
@ -30,23 +30,25 @@
|
|||
|
||||
#include "spatial_editor_plugin.h"
|
||||
|
||||
#include "camera_matrix.h"
|
||||
#include "core/math/camera_matrix.h"
|
||||
#include "core/os/input.h"
|
||||
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/print_string.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "core/sort.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/plugins/animation_player_editor_plugin.h"
|
||||
#include "editor/plugins/script_editor_plugin.h"
|
||||
#include "editor/script_editor_debugger.h"
|
||||
#include "editor/spatial_editor_gizmos.h"
|
||||
#include "os/keyboard.h"
|
||||
#include "print_string.h"
|
||||
#include "project_settings.h"
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/3d/collision_shape.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/3d/physics_body.h"
|
||||
#include "scene/3d/visual_instance.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
#include "sort.h"
|
||||
|
||||
#define DISTANCE_DEFAULT 4
|
||||
|
||||
|
|
|
@ -32,8 +32,27 @@
|
|||
|
||||
#include "geometry.h"
|
||||
#include "quick_hull.h"
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/3d/audio_stream_player_3d.h"
|
||||
#include "scene/3d/baked_lightmap.h"
|
||||
#include "scene/3d/collision_polygon.h"
|
||||
#include "scene/3d/collision_shape.h"
|
||||
#include "scene/3d/gi_probe.h"
|
||||
#include "scene/3d/light.h"
|
||||
#include "scene/3d/listener.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/3d/navigation_mesh.h"
|
||||
#include "scene/3d/particles.h"
|
||||
#include "scene/3d/physics_joint.h"
|
||||
#include "scene/3d/portal.h"
|
||||
#include "scene/3d/position_3d.h"
|
||||
#include "scene/3d/ray_cast.h"
|
||||
#include "scene/3d/reflection_probe.h"
|
||||
#include "scene/3d/room_instance.h"
|
||||
#include "scene/3d/soft_body.h"
|
||||
#include "scene/3d/spring_arm.h"
|
||||
#include "scene/3d/sprite_3d.h"
|
||||
#include "scene/3d/vehicle_body.h"
|
||||
#include "scene/3d/visibility_notifier.h"
|
||||
#include "scene/resources/box_shape.h"
|
||||
#include "scene/resources/capsule_shape.h"
|
||||
#include "scene/resources/convex_polygon_shape.h"
|
||||
|
@ -44,12 +63,6 @@
|
|||
#include "scene/resources/sphere_shape.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
|
||||
// Keep small children away from this file.
|
||||
// It's so ugly it will eat them alive
|
||||
|
||||
// The previous comment is kept only for historical reasons.
|
||||
// No children will be harmed by the viewing of this file... hopefully.
|
||||
|
||||
#define HANDLE_HALF_SIZE 9.5
|
||||
|
||||
bool EditorSpatialGizmo::can_draw() const {
|
||||
|
|
|
@ -32,27 +32,7 @@
|
|||
#define SPATIAL_EDITOR_GIZMOS_H
|
||||
|
||||
#include "editor/plugins/spatial_editor_plugin.h"
|
||||
#include "scene/3d/audio_stream_player_3d.h"
|
||||
#include "scene/3d/baked_lightmap.h"
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/3d/collision_polygon.h"
|
||||
#include "scene/3d/collision_shape.h"
|
||||
#include "scene/3d/gi_probe.h"
|
||||
#include "scene/3d/light.h"
|
||||
#include "scene/3d/listener.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/3d/navigation_mesh.h"
|
||||
#include "scene/3d/particles.h"
|
||||
#include "scene/3d/physics_joint.h"
|
||||
#include "scene/3d/portal.h"
|
||||
#include "scene/3d/position_3d.h"
|
||||
#include "scene/3d/ray_cast.h"
|
||||
#include "scene/3d/reflection_probe.h"
|
||||
#include "scene/3d/room_instance.h"
|
||||
#include "scene/3d/spring_arm.h"
|
||||
#include "scene/3d/sprite_3d.h"
|
||||
#include "scene/3d/vehicle_body.h"
|
||||
#include "scene/3d/visibility_notifier.h"
|
||||
|
||||
class Camera;
|
||||
|
||||
|
|
|
@ -30,9 +30,7 @@
|
|||
|
||||
#include "cpu_particles_2d.h"
|
||||
|
||||
#include "scene/3d/particles.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
//#include "scene/resources/particles_material.h"
|
||||
#include "servers/visual_server.h"
|
||||
|
||||
void CPUParticles2D::set_emitting(bool p_emitting) {
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
|
||||
#ifndef CPU_PARTICLES_2D_H
|
||||
#define CPU_PARTICLES_2D_H
|
||||
|
||||
#include "rid.h"
|
||||
#include "scene/2d/node_2d.h"
|
||||
#include "scene/main/timer.h"
|
||||
#include "scene/resources/material.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
|
|
|
@ -30,10 +30,13 @@
|
|||
|
||||
#include "particles_2d.h"
|
||||
|
||||
#include "engine.h"
|
||||
#include "scene/3d/particles.h"
|
||||
#include "scene/resources/particles_material.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "core/engine.h"
|
||||
#endif
|
||||
|
||||
void Particles2D::set_emitting(bool p_emitting) {
|
||||
|
||||
VS::get_singleton()->particles_set_emitting(particles, p_emitting);
|
||||
|
@ -114,7 +117,7 @@ void Particles2D::set_process_material(const Ref<Material> &p_material) {
|
|||
process_material = p_material;
|
||||
Ref<ParticlesMaterial> pm = p_material;
|
||||
if (pm.is_valid() && !pm->get_flag(ParticlesMaterial::FLAG_DISABLE_Z) && pm->get_gravity() == Vector3(0, -9.8, 0)) {
|
||||
//likely a new material, modify it!
|
||||
// Likely a new (3D) material, modify it to match 2D space
|
||||
pm->set_flag(ParticlesMaterial::FLAG_DISABLE_Z, true);
|
||||
pm->set_gravity(Vector3(0, 98, 0));
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef PARTICLES_FRAME_H
|
||||
#define PARTICLES_FRAME_H
|
||||
#ifndef PARTICLES_2D_H
|
||||
#define PARTICLES_2D_H
|
||||
|
||||
#include "rid.h"
|
||||
#include "scene/2d/node_2d.h"
|
||||
#include "scene/resources/color_ramp.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
class Particles2D : public Node2D {
|
||||
|
@ -132,4 +132,4 @@ public:
|
|||
|
||||
VARIANT_ENUM_CAST(Particles2D::DrawOrder)
|
||||
|
||||
#endif // PARTICLES_FRAME_H
|
||||
#endif // PARTICLES_2D_H
|
||||
|
|
|
@ -30,10 +30,9 @@
|
|||
|
||||
#include "cpu_particles.h"
|
||||
|
||||
#include "particles.h"
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
#include "scene/3d/particles.h"
|
||||
#include "scene/resources/particles_material.h"
|
||||
#include "servers/visual_server.h"
|
||||
|
||||
AABB CPUParticles::get_aabb() const {
|
||||
|
|
|
@ -30,10 +30,9 @@
|
|||
|
||||
#ifndef CPU_PARTICLES_H
|
||||
#define CPU_PARTICLES_H
|
||||
|
||||
#include "rid.h"
|
||||
#include "scene/3d/visual_instance.h"
|
||||
#include "scene/main/timer.h"
|
||||
#include "scene/resources/material.h"
|
||||
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -28,12 +28,11 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUALINSTANCEPARTICLES_H
|
||||
#define VISUALINSTANCEPARTICLES_H
|
||||
#ifndef PARTICLES_H
|
||||
#define PARTICLES_H
|
||||
|
||||
#include "rid.h"
|
||||
#include "scene/3d/visual_instance.h"
|
||||
#include "scene/main/timer.h"
|
||||
#include "scene/resources/material.h"
|
||||
|
||||
/**
|
||||
|
@ -135,269 +134,4 @@ public:
|
|||
|
||||
VARIANT_ENUM_CAST(Particles::DrawOrder)
|
||||
|
||||
class ParticlesMaterial : public Material {
|
||||
|
||||
GDCLASS(ParticlesMaterial, Material)
|
||||
|
||||
public:
|
||||
enum Parameter {
|
||||
|
||||
PARAM_INITIAL_LINEAR_VELOCITY,
|
||||
PARAM_ANGULAR_VELOCITY,
|
||||
PARAM_ORBIT_VELOCITY,
|
||||
PARAM_LINEAR_ACCEL,
|
||||
PARAM_RADIAL_ACCEL,
|
||||
PARAM_TANGENTIAL_ACCEL,
|
||||
PARAM_DAMPING,
|
||||
PARAM_ANGLE,
|
||||
PARAM_SCALE,
|
||||
PARAM_HUE_VARIATION,
|
||||
PARAM_ANIM_SPEED,
|
||||
PARAM_ANIM_OFFSET,
|
||||
PARAM_MAX
|
||||
};
|
||||
|
||||
enum Flags {
|
||||
FLAG_ALIGN_Y_TO_VELOCITY,
|
||||
FLAG_ROTATE_Y,
|
||||
FLAG_DISABLE_Z,
|
||||
FLAG_ANIM_LOOP,
|
||||
FLAG_MAX
|
||||
};
|
||||
|
||||
enum EmissionShape {
|
||||
EMISSION_SHAPE_POINT,
|
||||
EMISSION_SHAPE_SPHERE,
|
||||
EMISSION_SHAPE_BOX,
|
||||
EMISSION_SHAPE_POINTS,
|
||||
EMISSION_SHAPE_DIRECTED_POINTS,
|
||||
};
|
||||
|
||||
private:
|
||||
union MaterialKey {
|
||||
|
||||
struct {
|
||||
uint32_t texture_mask : 16;
|
||||
uint32_t texture_color : 1;
|
||||
uint32_t flags : 4;
|
||||
uint32_t emission_shape : 2;
|
||||
uint32_t trail_size_texture : 1;
|
||||
uint32_t trail_color_texture : 1;
|
||||
uint32_t invalid_key : 1;
|
||||
uint32_t has_emission_color : 1;
|
||||
};
|
||||
|
||||
uint32_t key;
|
||||
|
||||
bool operator<(const MaterialKey &p_key) const {
|
||||
return key < p_key.key;
|
||||
}
|
||||
};
|
||||
|
||||
struct ShaderData {
|
||||
RID shader;
|
||||
int users;
|
||||
};
|
||||
|
||||
static Map<MaterialKey, ShaderData> shader_map;
|
||||
|
||||
MaterialKey current_key;
|
||||
|
||||
_FORCE_INLINE_ MaterialKey _compute_key() const {
|
||||
|
||||
MaterialKey mk;
|
||||
mk.key = 0;
|
||||
for (int i = 0; i < PARAM_MAX; i++) {
|
||||
if (tex_parameters[i].is_valid()) {
|
||||
mk.texture_mask |= (1 << i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < FLAG_MAX; i++) {
|
||||
if (flags[i]) {
|
||||
mk.flags |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
mk.texture_color = color_ramp.is_valid() ? 1 : 0;
|
||||
mk.emission_shape = emission_shape;
|
||||
mk.trail_color_texture = trail_color_modifier.is_valid() ? 1 : 0;
|
||||
mk.trail_size_texture = trail_size_modifier.is_valid() ? 1 : 0;
|
||||
mk.has_emission_color = emission_shape >= EMISSION_SHAPE_POINTS && emission_color_texture.is_valid();
|
||||
|
||||
return mk;
|
||||
}
|
||||
|
||||
static Mutex *material_mutex;
|
||||
static SelfList<ParticlesMaterial>::List dirty_materials;
|
||||
|
||||
struct ShaderNames {
|
||||
StringName spread;
|
||||
StringName flatness;
|
||||
StringName initial_linear_velocity;
|
||||
StringName initial_angle;
|
||||
StringName angular_velocity;
|
||||
StringName orbit_velocity;
|
||||
StringName linear_accel;
|
||||
StringName radial_accel;
|
||||
StringName tangent_accel;
|
||||
StringName damping;
|
||||
StringName scale;
|
||||
StringName hue_variation;
|
||||
StringName anim_speed;
|
||||
StringName anim_offset;
|
||||
|
||||
StringName initial_linear_velocity_random;
|
||||
StringName initial_angle_random;
|
||||
StringName angular_velocity_random;
|
||||
StringName orbit_velocity_random;
|
||||
StringName linear_accel_random;
|
||||
StringName radial_accel_random;
|
||||
StringName tangent_accel_random;
|
||||
StringName damping_random;
|
||||
StringName scale_random;
|
||||
StringName hue_variation_random;
|
||||
StringName anim_speed_random;
|
||||
StringName anim_offset_random;
|
||||
|
||||
StringName angle_texture;
|
||||
StringName angular_velocity_texture;
|
||||
StringName orbit_velocity_texture;
|
||||
StringName linear_accel_texture;
|
||||
StringName radial_accel_texture;
|
||||
StringName tangent_accel_texture;
|
||||
StringName damping_texture;
|
||||
StringName scale_texture;
|
||||
StringName hue_variation_texture;
|
||||
StringName anim_speed_texture;
|
||||
StringName anim_offset_texture;
|
||||
|
||||
StringName color;
|
||||
StringName color_ramp;
|
||||
|
||||
StringName emission_sphere_radius;
|
||||
StringName emission_box_extents;
|
||||
StringName emission_texture_point_count;
|
||||
StringName emission_texture_points;
|
||||
StringName emission_texture_normal;
|
||||
StringName emission_texture_color;
|
||||
|
||||
StringName trail_divisor;
|
||||
StringName trail_size_modifier;
|
||||
StringName trail_color_modifier;
|
||||
|
||||
StringName gravity;
|
||||
};
|
||||
|
||||
static ShaderNames *shader_names;
|
||||
|
||||
SelfList<ParticlesMaterial> element;
|
||||
|
||||
void _update_shader();
|
||||
_FORCE_INLINE_ void _queue_shader_change();
|
||||
_FORCE_INLINE_ bool _is_shader_dirty() const;
|
||||
|
||||
float spread;
|
||||
float flatness;
|
||||
|
||||
float parameters[PARAM_MAX];
|
||||
float randomness[PARAM_MAX];
|
||||
|
||||
Ref<Texture> tex_parameters[PARAM_MAX];
|
||||
Color color;
|
||||
Ref<Texture> color_ramp;
|
||||
|
||||
bool flags[FLAG_MAX];
|
||||
|
||||
EmissionShape emission_shape;
|
||||
float emission_sphere_radius;
|
||||
Vector3 emission_box_extents;
|
||||
Ref<Texture> emission_point_texture;
|
||||
Ref<Texture> emission_normal_texture;
|
||||
Ref<Texture> emission_color_texture;
|
||||
int emission_point_count;
|
||||
|
||||
bool anim_loop;
|
||||
|
||||
int trail_divisor;
|
||||
|
||||
Ref<CurveTexture> trail_size_modifier;
|
||||
Ref<GradientTexture> trail_color_modifier;
|
||||
|
||||
Vector3 gravity;
|
||||
|
||||
//do not save emission points here
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
virtual void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
public:
|
||||
void set_spread(float p_spread);
|
||||
float get_spread() const;
|
||||
|
||||
void set_flatness(float p_flatness);
|
||||
float get_flatness() const;
|
||||
|
||||
void set_param(Parameter p_param, float p_value);
|
||||
float get_param(Parameter p_param) const;
|
||||
|
||||
void set_param_randomness(Parameter p_param, float p_value);
|
||||
float get_param_randomness(Parameter p_param) const;
|
||||
|
||||
void set_param_texture(Parameter p_param, const Ref<Texture> &p_texture);
|
||||
Ref<Texture> get_param_texture(Parameter p_param) const;
|
||||
|
||||
void set_color(const Color &p_color);
|
||||
Color get_color() const;
|
||||
|
||||
void set_color_ramp(const Ref<Texture> &p_texture);
|
||||
Ref<Texture> get_color_ramp() const;
|
||||
|
||||
void set_flag(Flags p_flag, bool p_enable);
|
||||
bool get_flag(Flags p_flag) const;
|
||||
|
||||
void set_emission_shape(EmissionShape p_shape);
|
||||
void set_emission_sphere_radius(float p_radius);
|
||||
void set_emission_box_extents(Vector3 p_extents);
|
||||
void set_emission_point_texture(const Ref<Texture> &p_points);
|
||||
void set_emission_normal_texture(const Ref<Texture> &p_normals);
|
||||
void set_emission_color_texture(const Ref<Texture> &p_colors);
|
||||
void set_emission_point_count(int p_count);
|
||||
|
||||
EmissionShape get_emission_shape() const;
|
||||
float get_emission_sphere_radius() const;
|
||||
Vector3 get_emission_box_extents() const;
|
||||
Ref<Texture> get_emission_point_texture() const;
|
||||
Ref<Texture> get_emission_normal_texture() const;
|
||||
Ref<Texture> get_emission_color_texture() const;
|
||||
int get_emission_point_count() const;
|
||||
|
||||
void set_trail_divisor(int p_divisor);
|
||||
int get_trail_divisor() const;
|
||||
|
||||
void set_trail_size_modifier(const Ref<CurveTexture> &p_trail_size_modifier);
|
||||
Ref<CurveTexture> get_trail_size_modifier() const;
|
||||
|
||||
void set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier);
|
||||
Ref<GradientTexture> get_trail_color_modifier() const;
|
||||
|
||||
void set_gravity(const Vector3 &p_gravity);
|
||||
Vector3 get_gravity() const;
|
||||
|
||||
static void init_shaders();
|
||||
static void finish_shaders();
|
||||
static void flush_changes();
|
||||
|
||||
RID get_shader_rid() const;
|
||||
|
||||
virtual Shader::Mode get_shader_mode() const;
|
||||
|
||||
ParticlesMaterial();
|
||||
~ParticlesMaterial();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(ParticlesMaterial::Parameter)
|
||||
VARIANT_ENUM_CAST(ParticlesMaterial::Flags)
|
||||
VARIANT_ENUM_CAST(ParticlesMaterial::EmissionShape)
|
||||
|
||||
#endif
|
||||
#endif // PARTICLES_H
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
#include "scene/resources/mesh_data_tool.h"
|
||||
#include "scene/resources/mesh_library.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/particles_material.h"
|
||||
#include "scene/resources/plane_shape.h"
|
||||
#include "scene/resources/polygon_path_finder.h"
|
||||
#include "scene/resources/primitive_meshes.h"
|
||||
|
@ -165,8 +166,6 @@
|
|||
#include "scene/resources/world_2d.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
|
||||
#include "scene/3d/cpu_particles.h"
|
||||
#include "scene/3d/particles.h"
|
||||
#include "scene/3d/scenario_fx.h"
|
||||
#include "scene/3d/spatial.h"
|
||||
|
||||
|
@ -179,6 +178,7 @@
|
|||
#include "scene/3d/camera.h"
|
||||
#include "scene/3d/collision_polygon.h"
|
||||
#include "scene/3d/collision_shape.h"
|
||||
#include "scene/3d/cpu_particles.h"
|
||||
#include "scene/3d/gi_probe.h"
|
||||
#include "scene/3d/immediate_geometry.h"
|
||||
#include "scene/3d/interpolated_camera.h"
|
||||
|
@ -188,6 +188,7 @@
|
|||
#include "scene/3d/multimesh_instance.h"
|
||||
#include "scene/3d/navigation.h"
|
||||
#include "scene/3d/navigation_mesh.h"
|
||||
#include "scene/3d/particles.h"
|
||||
#include "scene/3d/path.h"
|
||||
#include "scene/3d/physics_body.h"
|
||||
#include "scene/3d/physics_joint.h"
|
||||
|
|
1259
scene/resources/particles_material.cpp
Normal file
1259
scene/resources/particles_material.cpp
Normal file
File diff suppressed because it is too large
Load diff
302
scene/resources/particles_material.h
Normal file
302
scene/resources/particles_material.h
Normal file
|
@ -0,0 +1,302 @@
|
|||
/*************************************************************************/
|
||||
/* particles_material.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rid.h"
|
||||
#include "scene/resources/material.h"
|
||||
|
||||
#ifndef PARTICLES_MATERIAL_H
|
||||
#define PARTICLES_MATERIAL_H
|
||||
|
||||
class ParticlesMaterial : public Material {
|
||||
|
||||
GDCLASS(ParticlesMaterial, Material)
|
||||
|
||||
public:
|
||||
enum Parameter {
|
||||
|
||||
PARAM_INITIAL_LINEAR_VELOCITY,
|
||||
PARAM_ANGULAR_VELOCITY,
|
||||
PARAM_ORBIT_VELOCITY,
|
||||
PARAM_LINEAR_ACCEL,
|
||||
PARAM_RADIAL_ACCEL,
|
||||
PARAM_TANGENTIAL_ACCEL,
|
||||
PARAM_DAMPING,
|
||||
PARAM_ANGLE,
|
||||
PARAM_SCALE,
|
||||
PARAM_HUE_VARIATION,
|
||||
PARAM_ANIM_SPEED,
|
||||
PARAM_ANIM_OFFSET,
|
||||
PARAM_MAX
|
||||
};
|
||||
|
||||
enum Flags {
|
||||
FLAG_ALIGN_Y_TO_VELOCITY,
|
||||
FLAG_ROTATE_Y,
|
||||
FLAG_DISABLE_Z,
|
||||
FLAG_ANIM_LOOP,
|
||||
FLAG_MAX
|
||||
};
|
||||
|
||||
enum EmissionShape {
|
||||
EMISSION_SHAPE_POINT,
|
||||
EMISSION_SHAPE_SPHERE,
|
||||
EMISSION_SHAPE_BOX,
|
||||
EMISSION_SHAPE_POINTS,
|
||||
EMISSION_SHAPE_DIRECTED_POINTS,
|
||||
};
|
||||
|
||||
private:
|
||||
union MaterialKey {
|
||||
|
||||
struct {
|
||||
uint32_t texture_mask : 16;
|
||||
uint32_t texture_color : 1;
|
||||
uint32_t flags : 4;
|
||||
uint32_t emission_shape : 2;
|
||||
uint32_t trail_size_texture : 1;
|
||||
uint32_t trail_color_texture : 1;
|
||||
uint32_t invalid_key : 1;
|
||||
uint32_t has_emission_color : 1;
|
||||
};
|
||||
|
||||
uint32_t key;
|
||||
|
||||
bool operator<(const MaterialKey &p_key) const {
|
||||
return key < p_key.key;
|
||||
}
|
||||
};
|
||||
|
||||
struct ShaderData {
|
||||
RID shader;
|
||||
int users;
|
||||
};
|
||||
|
||||
static Map<MaterialKey, ShaderData> shader_map;
|
||||
|
||||
MaterialKey current_key;
|
||||
|
||||
_FORCE_INLINE_ MaterialKey _compute_key() const {
|
||||
|
||||
MaterialKey mk;
|
||||
mk.key = 0;
|
||||
for (int i = 0; i < PARAM_MAX; i++) {
|
||||
if (tex_parameters[i].is_valid()) {
|
||||
mk.texture_mask |= (1 << i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < FLAG_MAX; i++) {
|
||||
if (flags[i]) {
|
||||
mk.flags |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
mk.texture_color = color_ramp.is_valid() ? 1 : 0;
|
||||
mk.emission_shape = emission_shape;
|
||||
mk.trail_color_texture = trail_color_modifier.is_valid() ? 1 : 0;
|
||||
mk.trail_size_texture = trail_size_modifier.is_valid() ? 1 : 0;
|
||||
mk.has_emission_color = emission_shape >= EMISSION_SHAPE_POINTS && emission_color_texture.is_valid();
|
||||
|
||||
return mk;
|
||||
}
|
||||
|
||||
static Mutex *material_mutex;
|
||||
static SelfList<ParticlesMaterial>::List dirty_materials;
|
||||
|
||||
struct ShaderNames {
|
||||
StringName spread;
|
||||
StringName flatness;
|
||||
StringName initial_linear_velocity;
|
||||
StringName initial_angle;
|
||||
StringName angular_velocity;
|
||||
StringName orbit_velocity;
|
||||
StringName linear_accel;
|
||||
StringName radial_accel;
|
||||
StringName tangent_accel;
|
||||
StringName damping;
|
||||
StringName scale;
|
||||
StringName hue_variation;
|
||||
StringName anim_speed;
|
||||
StringName anim_offset;
|
||||
|
||||
StringName initial_linear_velocity_random;
|
||||
StringName initial_angle_random;
|
||||
StringName angular_velocity_random;
|
||||
StringName orbit_velocity_random;
|
||||
StringName linear_accel_random;
|
||||
StringName radial_accel_random;
|
||||
StringName tangent_accel_random;
|
||||
StringName damping_random;
|
||||
StringName scale_random;
|
||||
StringName hue_variation_random;
|
||||
StringName anim_speed_random;
|
||||
StringName anim_offset_random;
|
||||
|
||||
StringName angle_texture;
|
||||
StringName angular_velocity_texture;
|
||||
StringName orbit_velocity_texture;
|
||||
StringName linear_accel_texture;
|
||||
StringName radial_accel_texture;
|
||||
StringName tangent_accel_texture;
|
||||
StringName damping_texture;
|
||||
StringName scale_texture;
|
||||
StringName hue_variation_texture;
|
||||
StringName anim_speed_texture;
|
||||
StringName anim_offset_texture;
|
||||
|
||||
StringName color;
|
||||
StringName color_ramp;
|
||||
|
||||
StringName emission_sphere_radius;
|
||||
StringName emission_box_extents;
|
||||
StringName emission_texture_point_count;
|
||||
StringName emission_texture_points;
|
||||
StringName emission_texture_normal;
|
||||
StringName emission_texture_color;
|
||||
|
||||
StringName trail_divisor;
|
||||
StringName trail_size_modifier;
|
||||
StringName trail_color_modifier;
|
||||
|
||||
StringName gravity;
|
||||
};
|
||||
|
||||
static ShaderNames *shader_names;
|
||||
|
||||
SelfList<ParticlesMaterial> element;
|
||||
|
||||
void _update_shader();
|
||||
_FORCE_INLINE_ void _queue_shader_change();
|
||||
_FORCE_INLINE_ bool _is_shader_dirty() const;
|
||||
|
||||
float spread;
|
||||
float flatness;
|
||||
|
||||
float parameters[PARAM_MAX];
|
||||
float randomness[PARAM_MAX];
|
||||
|
||||
Ref<Texture> tex_parameters[PARAM_MAX];
|
||||
Color color;
|
||||
Ref<Texture> color_ramp;
|
||||
|
||||
bool flags[FLAG_MAX];
|
||||
|
||||
EmissionShape emission_shape;
|
||||
float emission_sphere_radius;
|
||||
Vector3 emission_box_extents;
|
||||
Ref<Texture> emission_point_texture;
|
||||
Ref<Texture> emission_normal_texture;
|
||||
Ref<Texture> emission_color_texture;
|
||||
int emission_point_count;
|
||||
|
||||
bool anim_loop;
|
||||
|
||||
int trail_divisor;
|
||||
|
||||
Ref<CurveTexture> trail_size_modifier;
|
||||
Ref<GradientTexture> trail_color_modifier;
|
||||
|
||||
Vector3 gravity;
|
||||
|
||||
//do not save emission points here
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
virtual void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
public:
|
||||
void set_spread(float p_spread);
|
||||
float get_spread() const;
|
||||
|
||||
void set_flatness(float p_flatness);
|
||||
float get_flatness() const;
|
||||
|
||||
void set_param(Parameter p_param, float p_value);
|
||||
float get_param(Parameter p_param) const;
|
||||
|
||||
void set_param_randomness(Parameter p_param, float p_value);
|
||||
float get_param_randomness(Parameter p_param) const;
|
||||
|
||||
void set_param_texture(Parameter p_param, const Ref<Texture> &p_texture);
|
||||
Ref<Texture> get_param_texture(Parameter p_param) const;
|
||||
|
||||
void set_color(const Color &p_color);
|
||||
Color get_color() const;
|
||||
|
||||
void set_color_ramp(const Ref<Texture> &p_texture);
|
||||
Ref<Texture> get_color_ramp() const;
|
||||
|
||||
void set_flag(Flags p_flag, bool p_enable);
|
||||
bool get_flag(Flags p_flag) const;
|
||||
|
||||
void set_emission_shape(EmissionShape p_shape);
|
||||
void set_emission_sphere_radius(float p_radius);
|
||||
void set_emission_box_extents(Vector3 p_extents);
|
||||
void set_emission_point_texture(const Ref<Texture> &p_points);
|
||||
void set_emission_normal_texture(const Ref<Texture> &p_normals);
|
||||
void set_emission_color_texture(const Ref<Texture> &p_colors);
|
||||
void set_emission_point_count(int p_count);
|
||||
|
||||
EmissionShape get_emission_shape() const;
|
||||
float get_emission_sphere_radius() const;
|
||||
Vector3 get_emission_box_extents() const;
|
||||
Ref<Texture> get_emission_point_texture() const;
|
||||
Ref<Texture> get_emission_normal_texture() const;
|
||||
Ref<Texture> get_emission_color_texture() const;
|
||||
int get_emission_point_count() const;
|
||||
|
||||
void set_trail_divisor(int p_divisor);
|
||||
int get_trail_divisor() const;
|
||||
|
||||
void set_trail_size_modifier(const Ref<CurveTexture> &p_trail_size_modifier);
|
||||
Ref<CurveTexture> get_trail_size_modifier() const;
|
||||
|
||||
void set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier);
|
||||
Ref<GradientTexture> get_trail_color_modifier() const;
|
||||
|
||||
void set_gravity(const Vector3 &p_gravity);
|
||||
Vector3 get_gravity() const;
|
||||
|
||||
static void init_shaders();
|
||||
static void finish_shaders();
|
||||
static void flush_changes();
|
||||
|
||||
RID get_shader_rid() const;
|
||||
|
||||
virtual Shader::Mode get_shader_mode() const;
|
||||
|
||||
ParticlesMaterial();
|
||||
~ParticlesMaterial();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(ParticlesMaterial::Parameter)
|
||||
VARIANT_ENUM_CAST(ParticlesMaterial::Flags)
|
||||
VARIANT_ENUM_CAST(ParticlesMaterial::EmissionShape)
|
||||
|
||||
#endif // PARTICLES_MATERIAL_H
|
Loading…
Reference in a new issue