goat3d

view src/node.cc @ 103:45a9d493e98c

fixed the input latency issue by calling QWidget::update() instead of QGLWidget::updateGL() update schedules an update instead of redrawing immediately.
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 12 Sep 2015 17:40:02 +0300
parents 76dea247f75c
children
line source
1 /*
2 goat3d - 3D scene, character, and animation file format library.
3 Copyright (C) 2013-2014 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include <algorithm>
19 #include <string.h>
20 #include "node.h"
22 using namespace g3dimpl;
24 Node::Node()
25 {
26 obj = 0;
27 bbox_valid = false;
28 }
30 void Node::set_object(Object *obj)
31 {
32 this->obj = obj;
33 bbox_valid = false;
34 }
36 Object *Node::get_object()
37 {
38 bbox_valid = false;
39 return obj;
40 }
42 const Object *Node::get_object() const
43 {
44 return obj;
45 }
47 const AABox &Node::get_bounds() const
48 {
49 if(!bbox_valid) {
50 Matrix4x4 xform;
51 get_xform(0, &xform);
52 bbox = obj ? obj->get_bounds(xform) : AABox();
54 for(int i=0; i<get_children_count(); i++) {
55 bbox = aabox_union(bbox, ((Node*)get_child(i))->get_bounds());
56 }
57 bbox_valid = true;
58 }
60 return bbox;
61 }
63 void g3dimpl::delete_node_tree(Node *n)
64 {
65 if(!n) return;
67 for(int i=0; i<n->get_children_count(); i++) {
68 delete_node_tree((Node*)n->get_child(i));
69 }
70 delete n;
71 }