aboutsummaryrefslogtreecommitdiff
path: root/main/tests/test_detailer.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--main/tests/test_detailer.cpp98
1 files changed, 41 insertions, 57 deletions
diff --git a/main/tests/test_detailer.cpp b/main/tests/test_detailer.cpp
index 5dba7c3f7..1f2be80c3 100644
--- a/main/tests/test_detailer.cpp
+++ b/main/tests/test_detailer.cpp
@@ -27,15 +27,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "test_detailer.h"
-#include "servers/visual_server.h"
-#include "os/main_loop.h"
+#include "geometry.h"
#include "math_funcs.h"
+#include "os/main_loop.h"
#include "print_string.h"
-#include "geometry.h"
#include "quick_hull.h"
+#include "servers/visual_server.h"
namespace TestMultiMesh {
-
class TestMainLoop : public MainLoop {
RID instance;
@@ -47,16 +46,15 @@ class TestMainLoop : public MainLoop {
#define MULTIMESH_COUNT 1500
- float ofs_x,ofs_y;
+ float ofs_x, ofs_y;
bool quit;
-public:
-
+public:
virtual void _update_qh() {
- VisualServer *vs=VisualServer::get_singleton();
+ VisualServer *vs = VisualServer::get_singleton();
Vector<Vector3> vts;
-/*
+ /*
static const int s = 20;
for(int i=0;i<s;i++) {
@@ -83,7 +81,7 @@ public:
vts.push_back(Vector3(0,-1,0));
vts.push_back(Vector3(1,0,0));
vts.push_back(Vector3(-1,0,0));*/
-/*
+ /*
vts.push_back(Vector3(1,1,1));
vts.push_back(Vector3(1,-1,1));
vts.push_back(Vector3(-1,1,1));
@@ -94,19 +92,16 @@ public:
vts.push_back(Vector3(-1,-1,-1));
*/
-
- DVector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5,0.7,4,Vector3::AXIS_Z);
+ DVector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5, 0.7, 4, Vector3::AXIS_Z);
Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
- vts=convex_data.vertices;
+ vts = convex_data.vertices;
Geometry::MeshData md;
- Error err = QuickHull::build(vts,md);
- print_line("ERR: "+itos(err));
-
- vs->mesh_remove_surface(mesh,0);
- vs->mesh_add_surface_from_mesh_data(mesh,md);
-
+ Error err = QuickHull::build(vts, md);
+ print_line("ERR: " + itos(err));
+ vs->mesh_remove_surface(mesh, 0);
+ vs->mesh_add_surface_from_mesh_data(mesh, md);
//vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME);
@@ -118,71 +113,64 @@ public:
RID tcmat = vs->mesh_surface_get_material(test_cube,0);
vs->material_set_shader(tcmat,sm);
*/
-
}
- virtual void input_event(const InputEvent& p_event) {
+ virtual void input_event(const InputEvent &p_event) {
- if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&4) {
+ if (p_event.type == InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask & 4) {
- ofs_x+=p_event.mouse_motion.relative_y/200.0;
- ofs_y+=p_event.mouse_motion.relative_x/200.0;
+ ofs_x += p_event.mouse_motion.relative_y / 200.0;
+ ofs_y += p_event.mouse_motion.relative_x / 200.0;
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index==1) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index == 1) {
QuickHull::debug_stop_after++;
_update_qh();
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index==2) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index == 2) {
- if (QuickHull::debug_stop_after>0)
+ if (QuickHull::debug_stop_after > 0)
QuickHull::debug_stop_after--;
_update_qh();
}
-
-
}
virtual void request_quit() {
- quit=true;
+ quit = true;
}
-
-
virtual void init() {
- VisualServer *vs=VisualServer::get_singleton();
-
+ VisualServer *vs = VisualServer::get_singleton();
mesh = vs->mesh_create();
scenario = vs->scenario_create();
- QuickHull::debug_stop_after=0;
+ QuickHull::debug_stop_after = 0;
_update_qh();
- instance = vs->instance_create2(mesh,scenario);
+ instance = vs->instance_create2(mesh, scenario);
camera = vs->camera_create();
-
- vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
+ vs->camera_set_perspective(camera, 60.0, 0.1, 100.0);
viewport = vs->viewport_create();
- vs->viewport_attach_camera( viewport, camera );
+ vs->viewport_attach_camera(viewport, camera);
vs->viewport_attach_to_screen(viewport);
- vs->viewport_set_scenario( viewport, scenario );
+ vs->viewport_set_scenario(viewport, scenario);
- vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,0,2 ) ) );
+ vs->camera_set_transform(camera, Transform(Matrix3(), Vector3(0, 0, 2)));
- RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
+ RID lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL);
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.3,0.3,0.3) );
- light = vs->instance_create2( lightaux,scenario );
- vs->instance_set_transform(light,Transform(Matrix3(Vector3(0.1,0.4,0.7).normalized(),0.9)));
+ light = vs->instance_create2(lightaux, scenario);
+ vs->instance_set_transform(light, Transform(Matrix3(Vector3(0.1, 0.4, 0.7).normalized(), 0.9)));
- ofs_x=0;
- ofs_y=0;
- quit=false;
+ ofs_x = 0;
+ ofs_y = 0;
+ quit = false;
}
virtual bool idle(float p_time) {
@@ -191,27 +179,23 @@ public:
virtual bool iteration(float p_time) {
- VisualServer *vs=VisualServer::get_singleton();
+ VisualServer *vs = VisualServer::get_singleton();
Transform tr_camera;
- tr_camera.rotate( Vector3(0,1,0), ofs_y );
- tr_camera.rotate( Vector3(1,0,0),ofs_x );
- tr_camera.translate(0,0,10);
+ tr_camera.rotate(Vector3(0, 1, 0), ofs_y);
+ tr_camera.rotate(Vector3(1, 0, 0), ofs_x);
+ tr_camera.translate(0, 0, 10);
- vs->camera_set_transform( camera, tr_camera );
+ vs->camera_set_transform(camera, tr_camera);
return quit;
}
virtual void finish() {
-
}
-
};
-MainLoop* test() {
+MainLoop *test() {
return memnew(TestMainLoop);
-
}
-
}