|
16 | 16 | #include <vtkExecutive.h>
|
17 | 17 | #include <vtkRenderWindowInteractor.h>
|
18 | 18 |
|
19 |
| - |
20 |
| -//bool is_different(const vtkMatrix4x4* first, const vtkMatrix4x4* second) { |
21 |
| -// for (int i = 0; i < 4; ++i) |
22 |
| -// for (int j = 0; j < 4; ++j) |
23 |
| -// if (first->GetElement(i, j) != second->GetElement(i, j)) return true; |
24 |
| -// return false; |
25 |
| -//} |
26 |
| - |
27 | 19 | enum FrustumCull
|
28 | 20 | {
|
29 | 21 | INSIDE_FRUSTUM,
|
@@ -72,82 +64,6 @@ int intersect(vtkCamera* camera, const vtkBoundingBox& bbox, double aspect_ratio
|
72 | 64 | return result;
|
73 | 65 | }
|
74 | 66 |
|
75 |
| -//class CheckVisibilityCallback: public vtkCallbackCommand { |
76 |
| -//public: |
77 |
| -// static CheckVisibilityCallback* New(); |
78 |
| -// vtkTypeMacro(CheckVisibilityCallback, vtkCallbackCommand); |
79 |
| -// |
80 |
| -// // Here we Create a vtkCallbackCommand and reimplement it. |
81 |
| -// void Execute(vtkObject* caller, unsigned long evId, void*) override |
82 |
| -// { |
83 |
| -// std::cout << "Camera moved" << std::endl; |
84 |
| -// // Note the use of reinterpret_cast to cast the caller to the expected type. |
85 |
| -// auto camera = Mapper->Renderer->GetActiveCamera();//reinterpret_cast<vtkCamera*>(caller); |
86 |
| -// vtkVector3d camera_position; |
87 |
| -// camera->GetPosition(camera_position.GetData()); |
88 |
| -// vtkQuaterniond camera_orientation(camera->GetOrientationWXYZ()); |
89 |
| -// vtkSmartPointer<vtkMatrix4x4> projection_matrix; |
90 |
| -// projection_matrix.TakeReference(camera->GetProjectionTransformMatrix(Mapper->Renderer)); |
91 |
| -// |
92 |
| -// vtkVector3d camera_position_difference; |
93 |
| -// vtkMath::Subtract(camera_position.GetData(), LastPosition.GetData(), camera_position_difference.GetData()); |
94 |
| -// bool projection_different = true; |
95 |
| -// if(LastProjection) { |
96 |
| -// projection_different = is_different(projection_matrix, LastProjection); |
97 |
| -// } |
98 |
| -// if (!projection_different |
99 |
| -// && camera_position_difference.Norm() < 0.01f |
100 |
| -// && (camera_orientation - LastOrientation).Norm() < 0.01f) |
101 |
| -// return; |
102 |
| -// LastPosition = camera_position; |
103 |
| -// LastOrientation = camera_orientation; |
104 |
| -// LastProjection = projection_matrix; |
105 |
| -// if(Mapper->Renderer) |
106 |
| -// //std::cout << "Re-Rendering due to moved camera" << std::endl; |
107 |
| -// Mapper->Renderer->GetRenderWindow()->Render(); // force a render |
108 |
| -// } |
109 |
| -// CheckVisibilityCallback(): Mapper(nullptr) |
110 |
| -// { |
111 |
| -// } |
112 |
| -// |
113 |
| -// // Set pointers to any clientData or callData here. |
114 |
| -// vtkTileHierarchyMapper* Mapper; |
115 |
| -// vtkVector3d LastPosition; |
116 |
| -// vtkQuaterniond LastOrientation; |
117 |
| -// vtkSmartPointer<vtkMatrix4x4> LastProjection; |
118 |
| -//}; |
119 |
| -// |
120 |
| -//class ReRenderCallback: public vtkCallbackCommand { |
121 |
| -//public: |
122 |
| -// static ReRenderCallback* New(); |
123 |
| -// vtkTypeMacro(ReRenderCallback, vtkCallbackCommand); |
124 |
| -// |
125 |
| -// // Here we Create a vtkCallbackCommand and reimplement it. |
126 |
| -// void Execute(vtkObject* caller, unsigned long evId, void*) override |
127 |
| -// { |
128 |
| -// // Note the use of reinterpret_cast to cast the caller to the expected type. |
129 |
| -// if (vtkCommand::TimerEvent == evId) { |
130 |
| -// if(Mapper->ForceUpdate && Mapper->Renderer) { |
131 |
| -// std::cout << "Re-rendering " << count++ << std::endl; |
132 |
| -// Mapper->Renderer->GetRenderWindow()->Render(); // force a render |
133 |
| -// } |
134 |
| -// } |
135 |
| -// } |
136 |
| -// ReRenderCallback(): Mapper(nullptr) |
137 |
| -// { |
138 |
| -// } |
139 |
| -// |
140 |
| -// // Set pointers to any clientData or callData here. |
141 |
| -// vtkTileHierarchyMapper* Mapper; |
142 |
| -// size_t count = 0; |
143 |
| -//}; |
144 |
| -// |
145 |
| -// |
146 |
| -//vtkStandardNewMacro(CheckVisibilityCallback); |
147 |
| -//vtkStandardNewMacro(ReRenderCallback); |
148 |
| - |
149 |
| - |
150 |
| - |
151 | 67 | vtkStandardNewMacro(vtkTileHierarchyMapper);
|
152 | 68 |
|
153 | 69 | vtkTileHierarchyMapper::vtkTileHierarchyMapper()
|
@@ -205,7 +121,7 @@ void vtkTileHierarchyMapper::OnNodeLoaded() {
|
205 | 121 | }
|
206 | 122 |
|
207 | 123 | void vtkTileHierarchyMapper::Render(vtkRenderer *ren, vtkActor *a) {
|
208 |
| - //std::cout << "Rendering" << std::endl; |
| 124 | + auto loader_state = Loader->PreRender(); |
209 | 125 | ForceUpdate = false;
|
210 | 126 |
|
211 | 127 | if(ren->GetRenderWindow()->GetActualSize()[1] < 10) {
|
@@ -250,6 +166,7 @@ void vtkTileHierarchyMapper::Render(vtkRenderer *ren, vtkActor *a) {
|
250 | 166 |
|
251 | 167 | }
|
252 | 168 | }
|
| 169 | + Loader->PostRender(std::move(loader_state)); |
253 | 170 | }
|
254 | 171 |
|
255 | 172 |
|
|
0 commit comments