ClipmapView.h
1 /************************************************************
2 * (C) Voxel Farm Inc. 2015
3 */
4 
5 #pragma once
6 
7 #include "Vector.h"
8 #include "mapindex.h"
9 #include "scene.h"
10 #include "Generator.h"
11 #include "BlockData.h"
12 #include "CellData.h"
13 #include "contour.h"
14 #include "ExternalMutex.h"
15 #include "StampMesh.h"
16 #include "Clipboard.h"
17 #include "PhysicsData.h"
18 
19 namespace VoxelFarm
20 {
21  // forward declaration
22  class CClipmapView;
23 
27  const int VOXEL_OCCUPANCY_BLOCK_DATASIZE = VOXEL_OCCUPANCY_BLOCK*VOXEL_OCCUPANCY_BLOCK*VOXEL_OCCUPANCY_BLOCK;
29  enum BuildCursorMode {BUILD_CURSOR_ADD, BUILD_CURSOR_SMOOTH, BUILD_CURSOR_STAMP};
30 
31  // Utility functions ($$$REI to be moved elsewhere)
32  void ClearBoxArea(IBlockData* blockData, const double kernel[8][3], bool fullErase, TSet<CellId>* changedCells);
33 
35  inline int getVoxelOccupancyIndex(int x, int y, int z)
36  {
37  return (VOXEL_OCCUPANCY_BLOCK * VOXEL_OCCUPANCY_BLOCK * z) + (VOXEL_OCCUPANCY_BLOCK * x) + y;
38  }
39 
40  struct VoxelHitInfo
41  {
43  bool valid;
44 
47 
49  int voxel[3];
50 
53 
55  double position[3];
56 
58  double normal[3];
59 
61  int material;
62  };
63 
66  {
67  public:
70  {
71  public:
73  virtual void requestCells(CellId* cells, int count, CClipmapView* view) = 0;
74  };
75  public:
77  ~CClipmapView();
78  public:
85  public:
87  void enterCriticalSection();
89  void leaveCriticalSection();
91  void disposeScene(Scene* old, Scene* current);
95  void notifyCellBaked(CCellData* cellData);
99  void notifyCellBakedSeams(CCellData* cellData);
103  void notifyCellDestroyed(CCellData* cellData);
104 
105  bool cellIsEmpty(CellId cell);
106 
108  bool sceneLoop(LODStats& stats);
109  bool recomputing;
110  void recomputeScene();
111 
113  bool contourLoop(CGenerator* threadGenerator, ContourThreadContext* tc, CCellData::ThreadContext* tcCellData, LODStats stats);
115  void sceneFade(bool& sceneChanged);
117  void garbageCollect();
119  unsigned char* createVoxelOccupancyData(ContourVoxelData* data);
121  void addBlock(LODStats& stats, int buildCursorSize, const int buildCursorSizes[3], const CellId& hitId, const int hitCell[3], const int hitHint[3], TSet<CellId>& changedCells);
123  void addBlock(LODStats& stats);
125  void removeBlock(LODStats& stats, int buildCursorSize, const int buildCursorSizes[3], const CellId& hitId, const int hitCell[3]);
127  void removeBlock(LODStats& stats);
129  void repairBlock(LODStats& stats, int buildCursorSize, const int buildCursorSizes[3], const CellId& hitId, const int hitCell[3]);
131  void repairBlock(LODStats& stats);
133  void smoothBlock(const int buildCursorSizes[3], const CellId& hitId, const int hitCell[3], int iterations, float blendWeight);
135  void smoothBlock();
137  void addSmoothBlock();
138 
140  void stampModel(
142  const double size[3],
144  Algebra::Quaternion rotations,
146  const double position[3],
148  Architecture::CArchitectureManager* architectureManager,
150  int moduleId,
156  IMeshStamMaterialSource* materials);
157 
159  void raiseBlock();
161  void raiseBlock(const int buildCursorSizes[3], const CellId& hitId, const int hitCell[3], int iterations, float blendWeight);
162 
163  void processModifiedCells(const TSet<CellId>& modifiedCells, bool deleting = false);
165  void copyToClipboard(
167  IClipboard* clipboard,
169  CellId c1, int x1, int y1, int z1,
171  CellId c2, int x2, int y2, int z2
172  );
173 
175  void pasteFromClipboard(
177  IClipboard* clipboard,
179  CellId c, int x, int y, int z
180  );
181 
183  void stampMesh(
185  double worldPos[3],
187  IMeshStampSource* mesh,
189  IMeshStamMaterialSource* materials,
191  const Algebra::Matrix& transform
192  );
193 
195  void stampMesh(
197  IMeshStampSource* mesh,
199  IMeshStamMaterialSource* materials,
201  const Algebra::Matrix& transform
202  );
203 
205  void stampVoxels(
207  double worldPos[3],
209  unsigned int* data,
211  int xsize, int ysize, int zsize,
213  IMeshStamMaterialSource* materials
214  );
215 
217  void stampVoxels(
219  unsigned int* data,
221  int xsize, int ysize, int zsize,
223  IMeshStamMaterialSource* materials
224  );
225 
227  void clearBoxArea(
228  // vertices of the box
229  const double kernel[8][3],
230  // Whether to erase all data (? Better documentation ?)
231  bool fullErase
232  );
233 
234  // For Physics Noise Brush Stamping
235  void stampMesh(IMeshStampSource* mesh, Physics::CNoiseBrush* noise, Physics::CVoxelBuffer* nVoxBuffer, IMeshStamMaterialSource* materials, const Algebra::Matrix& transform);
236 
239  void setLineOfSight(double x0, double y0, double z0, double x1, double y1, double z1);
241  void getViewPosition(double* p0, double* p1 = nullptr) const;
243  void getViewDirection(double dir[3]) const;
245  void getViewWorldPosition(double pos[3]) const;
247  void getBuildCursorSize(int sizes[3]) const;
254 
256  void hitPosChanged();
258  bool updateHitPos(
260  const int buildCursorSizes[3],
261  const double dir[3],
262  const double hitPos[3],
263  double hitNormal[3],
264  CellId& cellHitId,
265  int hitCell[3],
266  int hitHint[3]);
268  void updateHitPos();
270  double getMeshHeight(double x, double y, double z, bool& approximated, int& material, int medium = 0);
272  bool detectCollisionAABB(double boxcenter[3], double boxhalfsize[3]);
274  bool detectCollisionEllipsoid(double center[3], double radV, double radH, double pi[3], double push[3]);
275 
277  void beginChanges();
279  void endChanges();
281  void undo();
282 
283  public:
285  void setRemoteView(IRemoteView* remoteView);
287  void notifyRemoteCellsReady(CellId* cells, int count);
289  void notifyRemoteCellsChanged(CellId* cells, int count);
290  private:
291  IRemoteView* remoteView;
292  static const int MAX_CELL_REQUEST = 30000;
293  CellId cellRequestArray[MAX_CELL_REQUEST];
294  public:
296  typedef void UpdateViewerState();
299 
304 
306  class IEvents
307  {
308  public:
310  virtual void updateViewerState() = 0;
312  virtual CCellData* createCellData(CellId cell) = 0;
314  virtual void cellQueued(CellId cellId) = 0;
315  virtual void cellProcessed(CCellData* cellData) {};
316  virtual void cellEmpty(CellId cell) {};
317  virtual void cellsMeshed() {};
318  virtual void cellsBaked() {};
319  virtual void cellDestroyed(CellId cell) {};
320  };
322  void setEvents(IEvents* events);
323  private:
324  void notifyCellQueued(CellId cellId);
326  IEvents* events;
327  public:
331  bool started;
341  bool firstLoad;
342  int radiusLOD0;
343  bool compressMeshes;
344 
346  static const int GARBAGE_MAX_AGE = 5;
347 
348  // Dimensions for additional set to store voxel occupancy within a cell.
349  static const int VOXEL_OCCUPANCY_BLOCK = BLOCK_SIZE/2;
350  // Number of voxels to store voxel occupancy within a cell.
351  static const int VOXEL_OCCUPANCY_BLOCK_DATASIZE = VOXEL_OCCUPANCY_BLOCK*VOXEL_OCCUPANCY_BLOCK*VOXEL_OCCUPANCY_BLOCK;
352 
354  double speed;
356  double heading;
358  bool moving;
362  double xpos;
364  double ypos;
366  double zpos;
367  double xspeed;
368  double yspeed;
369  double zspeed;
371  double xoffs;
373  double yoffs;
375  double zoffs;
377  double zoom;
379  double slopeDamp;
381  double lastXpos;
383  double lastYpos;
385  double lastZpos;
387  double time;
388 
389  double sceneBounds[2][3];
390  double nextSceneBounds[2][3];
391 
392  // scene management
402  double sceneXpos;
404  double sceneYpos;
406  double sceneZpos;
408  double sceneFadeIn;
412  double oldSceneXpos;
414  double oldSceneYpos;
416  double oldSceneZpos;
418  unsigned int sceneTime;
420  unsigned int sceneCnt;
422  unsigned int renderTime;
424  unsigned int renderCnt;
428  typedef TMap<CellId, CCellData*> CellDataCache;
430  CellDataCache cellCache;
432  TMap<CellId, unsigned char*> voxelCache;
434  TDeque<CellId> downloadQueue;
436  TSet<CellId> downloadQueueSet;
438  TDeque<CellId> processQueue;
440  TVector<CCellData*> bakeQueue;
442  TSet<CellId> pendingCells;
444  TSet<CellId> emptyCells;
446  TSet<CCellData*> garbageCells;
448  TSet<CCellData*> deadMeat;
449  TSet<CCellData*> disposedCells;
450 
451  TSet<CellId> seamCreateQueue;
452  TSet<CellId> seamInProgress;
453  TVector<CCellData*> seamBakeQueue;
454  TSet<CellId> seamPendingCells;
455  TSet<CellId> seamRequested;
456 
458  TSet<CellId> pendingEditionCells; // these two queues track the state of the mesh. when the mesh is complete, we can create the physics mesh.
459  TSet<CellId> editionInProgress;
460  TSet<CellId> pendingBakeEditionCells; // this queue tracks the state of the display. when the cells are baked, we can release the fragments.
461 
470  bool cellsPendingBaking;
483 
484  // build/carve interface
486  int hitPosXi;
488  int hitPosYi;
490  int hitPosZi;
495  bool snapToGrid;
508 
509  void updateOffsets();
510 
511  // Elastic Fill Tool
513  bool fillMode;
515  double fillScope[8][3];
517  double fillWorldPos[3];
519  int fillStartDir[3];
521  int fillEndDir[3];
523  void beginFill();
525  void updateFillScope();
527  void endFill(IMeshStamMaterialSource* material);
528 
529  // stats
538  time_t lastSceneTime;
539  private:
540  unsigned char* tmpRayTraceBuffer;
542  bool recomputeHitPos;
543  public:
544  TList<std::pair<int, Scene*>> createdScenes;
545 
546  private:
547  static int planeBoxOverlap(double normal[3],double d, double maxbox[3]);
548  void computeCellSeams(CellId cell);
549 
551  private:
553  double cPitch;
555  double cYaw;
557  double cRoll;
558  public:
560  double cShiftX;
562  double cShiftY;
564  double cShiftZ;
566  double pitch()
567  {
568  return cPitch;
569  }
570  void pitch(double ang)
571  {
572  cPitch = ang;
573  if (cPitch > 90.f) cPitch = 90.f;
574  if (cPitch < -90.f) cPitch = -90.f;
575  }
577  double yaw()
578  {
579  return cYaw;
580  }
581  void yaw(double ang)
582  {
583  cYaw = ang;
584  if (cYaw > 360.f) cYaw -= 360.f;
585  if (cYaw < 0.f) cYaw += 360.f;
586  }
588  double roll()
589  {
590  return cRoll;
591  }
592  void roll(double ang)
593  {
594  cRoll = ang;
595  if (cRoll > 360.f) cRoll -= 360.f;
596  if (cRoll < 0.f) cRoll += 360.f;
597  }
598  };
599 
600  extern const int VoxelCorners[8][3];
601 }
int buildCursorSize
Edition cursor size in voxels.
Definition: ClipmapView.h:499
double fillWorldPos[3]
Position of the starting face in world units.
Definition: ClipmapView.h:517
CellDataCache cellCache
A cache of recently built and used CCellData objects.
Definition: ClipmapView.h:430
ExternalMutex::Mutex dataLock
Critical section to allow multiple threads to collaborate loading and disposing Scenes.
Definition: ClipmapView.h:426
double ypos
Viewer coordinates along the Y axis.
Definition: ClipmapView.h:364
int buildCursorSizeY
Edition cursor size Y in voxels.
Definition: ClipmapView.h:503
void pasteFromClipboard(IClipboard *clipboard, CellId c, int x, int y, int z)
Paste voxels from clipboard into block layer.
TSet< CellId > downloadQueueSet
Set of Cells to be downloaded accordint to priority.
Definition: ClipmapView.h:436
void addBlock(LODStats &stats, int buildCursorSize, const int buildCursorSizes[3], const CellId &hitId, const int hitCell[3], const int hitHint[3], TSet< CellId > &changedCells)
Adds a block at the given edition coordinates.
VoxelFarm::Algebra::Vector getViewDirection() const
Get the current view direction.
Scene * scene
Current Scene.
Definition: ClipmapView.h:396
void notifyCellDestroyed(CCellData *cellData)
Notifies the host has destroyed the application data the cell.
bool cellsPendingUpdate
Signal there are cells pending an update. This often happens when the user builds or carves cells...
Definition: ClipmapView.h:469
double lineOfSightZ0
Line of sight start Z coordinate.
Definition: ClipmapView.h:476
TMap< CellId, unsigned char * > voxelCache
Voxel occupancy cache.
Definition: ClipmapView.h:432
int fillStartDir[3]
Direction of the starting face in only one axis (x, y or z)
Definition: ClipmapView.h:519
void sceneFade(bool &sceneChanged)
Morphs from the previous scene into the next.
double speed
Speed at which the view moves.
Definition: ClipmapView.h:354
double zoom
Zoom level.
Definition: ClipmapView.h:377
Combines several voxel layers into the final dataset sent to the contouring phase.
Definition: Generator.h:20
double getMeshHeight(double x, double y, double z, bool &approximated, int &material, int medium=0)
Computes the vertical position using meshes. This is used to implement walking.
bool approximatedPos
Signals whether the vertical position is accurate, based on the best octree level possible...
Definition: ClipmapView.h:360
bool sceneLoop(LODStats &stats)
Performs a scene loop iteration, which discovers if a new scene is needed and proceeds to request it...
void leaveCriticalSection()
Releases the critical section for the data that is shared by all threads using the view...
bool moving
Signals whether the viewer is moving or not.
Definition: ClipmapView.h:358
double oldSceneZpos
Z coordinates for previous Scene.
Definition: ClipmapView.h:416
Contains all classes and functions for the VoxelFarm engine.
void stampVoxels(double worldPos[3], unsigned int *data, int xsize, int ysize, int zsize, IMeshStamMaterialSource *materials)
It stamps a block of voxels data into block layer.
Contains all materials available in the system.
const int BLOCK_SIZE
Actual number of voxels in one Cell Dim once the margin is considered.
Definition: VoxelLayer.h:38
void updateHitPos()
Computes the location of the next block addition or removal.
bool detectCollisionAABB(double boxcenter[3], double boxhalfsize[3])
Detects collision of axis aligned bounding box against the view's geometry.
double pitch()
Camera rotation over the X axis (-90 is UP)
Definition: ClipmapView.h:566
CCellData * CreateCellData(CellId cell)
Prototype for event callback to create a celldata object. The client application must return a differ...
Definition: ClipmapView.h:301
int totalDownload
Total downloaded size in sizes.
Definition: ClipmapView.h:533
TSet< CellId > pendingEditionCells
List of Cells queued for edition purposes.
Definition: ClipmapView.h:458
int buildCursorSizeZ
Edition cursor size Z in voxels.
Definition: ClipmapView.h:505
int totalCells
Total processed cells.
Definition: ClipmapView.h:531
double lineOfSightY0
Line of sight start Y coordinate.
Definition: ClipmapView.h:474
void stampModel(const double size[3], Algebra::Quaternion rotations, const double position[3], Architecture::CArchitectureManager *architectureManager, int moduleId, Architecture::CPaletteDesc *palette, Architecture::PaletteType type, IMeshStamMaterialSource *materials)
Stamp a model from architecture.
An index of which Cells are empty and which ones contain information. For offline mode only...
Definition: mapindex.h:54
A 3D Vector.
Definition: Vector.h:34
double lineOfSightY1
Line of sight end Y coordinate.
Definition: ClipmapView.h:480
double normal[3]
voxel normal at the hit position
Definition: ClipmapView.h:58
unsigned int sceneCnt
Number of scences built.
Definition: ClipmapView.h:420
bool valid
whether there is a valid hit position (the rest of the data is not useful if this is false) ...
Definition: ClipmapView.h:43
const int VOXEL_OCCUPANCY_BLOCK_DATASIZE
Number of voxels to store voxel occupancy within a cell.
Definition: ClipmapView.h:27
TDeque< CellId > downloadQueue
List of Cells to be downloaded accordint to priority.
Definition: ClipmapView.h:434
A default implementation of IBlockData that also acts as a VoxelLayer.
Definition: BlockData.h:182
virtual void requestCells(CellId *cells, int count, CClipmapView *view)=0
The view uses this method to tell the implementor of the interface a list of cells is needed...
double lastXpos
Previous position along the X axis.
Definition: ClipmapView.h:381
UpdateViewerState * updateViewerState
Pointer to UpdateViewerState event callback.
Definition: ClipmapView.h:298
void smoothBlock()
Smooth block at the current edition coordinates.
int buildMaterial
Material that will be added at the edition point.
Definition: ClipmapView.h:494
VoxelHitInfo hitInfo
Voxel targeted for build/carve.
Definition: ClipmapView.h:492
int voxel[3]
voxel coordinates within the cell
Definition: ClipmapView.h:49
double zoffs
Additional offset for Viewer coordinates along the Z axis.
Definition: ClipmapView.h:375
double lineOfSightX0
Line of sight start X coordinate.
Definition: ClipmapView.h:472
Architecture system. It keeps a list of entities, their classes and the mesh instances they have prod...
int buildCursorSizeX
Edition cursor size X in voxels.
Definition: ClipmapView.h:501
void enterCriticalSection()
Acquires the critical section for the data that is shared by all threads using the view...
It allows to access to the faces and materials of a list of solids.
Definition: StampMesh.h:31
void raiseBlock()
Raise block at the current edition coordinates.
void copyToClipboard(IClipboard *clipboard, CellId c1, int x1, int y1, int z1, CellId c2, int x2, int y2, int z2)
Copy voxels to the Clipboard.
double lastZpos
Previous position along the Z axis.
Definition: ClipmapView.h:385
double sceneYpos
Y coordinates for the current scene.
Definition: ClipmapView.h:404
double cShiftY
Camera Shift in Y.
Definition: ClipmapView.h:562
double lastYpos
Previous position along the Y axis.
Definition: ClipmapView.h:383
static const int GARBAGE_MAX_AGE
Number of generations before Cells go to garbage.
Definition: ClipmapView.h:346
virtual CCellData * createCellData(CellId cell)=0
The client application must return a different types of celldata objects depending on the graphics AP...
double position[3]
position of the hit (in world space)
Definition: ClipmapView.h:55
bool started
Flags where the view has begun to produce scenes.
Definition: ClipmapView.h:331
void disposeScene(Scene *old, Scene *current)
Disposes a scene. Cells in the scene will be moved to the garbage list.
double cShiftZ
Camera Shift in Z.
Definition: ClipmapView.h:564
TMap< CellId, CCellData * > CellDataCache
Type definition for a map that allows caching CCellData objects.
Definition: ClipmapView.h:428
unsigned __int64 CellId
A 64bit integer that identifies a single world octree Cell.
Definition: mapindex.h:23
bool fillMode
It signals whether the fill tool is in use.
Definition: ClipmapView.h:513
TSet< CCellData * > deadMeat
Set of Cells to be disposed.
Definition: ClipmapView.h:448
Cells Scene
A Scene is a set of cells.
Definition: scene.h:12
CreateCellData * createCellData
Create celldata object event callback.
Definition: ClipmapView.h:303
void removeBlock(LODStats &stats, int buildCursorSize, const int buildCursorSizes[3], const CellId &hitId, const int hitCell[3])
Removes a block at the given edition coordinates.
void endFill(IMeshStamMaterialSource *material)
It ends the fill tool by stamping the designed box into a block layer.
Scene * newScene
A new Scene was just built.
Definition: ClipmapView.h:398
Clipboard interface.
Definition: Clipboard.h:17
int material
material of the hit voxel
Definition: ClipmapView.h:61
bool computeLods
Set to true if LODs should be re-computed.
Definition: ClipmapView.h:507
int lastCellGeneration
Generation of last batch of Cells.
Definition: ClipmapView.h:465
bool firstLoad
Signals whether the view has just loaded.
Definition: ClipmapView.h:341
Stores the information for a Cell that has already been converted to a polygonal mesh.
Definition: CellData.h:107
VoxelFarm::Algebra::Vector getViewPosition() const
Get the current camera position relative to the user's location.
int hitPosXi
Edition point X coordinate in voxels.
Definition: ClipmapView.h:486
unsigned int renderTime
Time spent rendering.
Definition: ClipmapView.h:422
CMaterialLibrary * materialLibrary
Points to the material library to be used by the view.
Definition: ClipmapView.h:80
bool detectCollisionEllipsoid(double center[3], double radV, double radH, double pi[3], double push[3])
Detects collision of axis aligned ellipsoid against the view's geometry.
Generation of voxel data and then meshes out if it can be time consuming. The engine allows multiple ...
Definition: contour.h:51
double xoffs
Additional offset for Viewer coordinates along the X axis.
Definition: ClipmapView.h:371
TDeque< CellId > processQueue
List of Cells to be processed.
Definition: ClipmapView.h:438
void beginFill()
It initializes the fill tool.
double zpos
Viewer coordinates along the Z axis.
Definition: ClipmapView.h:366
VoxelFarm::Algebra::Vector getViewWorldPosition() const
Get the current view position in world.
unsigned int sceneTime
Stats about scene build time.
Definition: ClipmapView.h:418
double cShiftX
Camera Shift in X.
Definition: ClipmapView.h:560
int outsideDirection[3]
voxel direction to the open side of the voxel
Definition: ClipmapView.h:52
double sceneFadeIn
Scene morph progress.
Definition: ClipmapView.h:408
void UpdateViewerState()
Prototype for event callback to update viewer position. This is called right before the view is rende...
Definition: ClipmapView.h:296
virtual void updateViewerState()=0
This is called right before the view is rendered. If desired this event can be used to query user inp...
A Matrix for 3D operations.
Definition: MatrixAlg.h:38
virtual void cellQueued(CellId cellId)=0
Called whenever a cell is queued for processing. Can be used to wake up processing threads...
double lineOfSightZ1
Line of sight end Z coordinate.
Definition: ClipmapView.h:482
unsigned int renderCnt
Number of frames rendered.
Definition: ClipmapView.h:424
const int VOXEL_OCCUPANCY_BLOCK
Dimensions for additional set to store voxel occupancy within a cell.
Definition: ClipmapView.h:25
StatTracker LODStats[LEVELS][STAT_NULL]
Used to track stats across all LOD.
Definition: VoxelLayer.h:530
double oldSceneYpos
Y coordinates for previous Scene.
Definition: ClipmapView.h:414
double yoffs
Additional offset for Viewer coordinates along the Y axis.
Definition: ClipmapView.h:373
void setEvents(IEvents *events)
Set event interface.
void notifyCellBakedSeams(CCellData *cellData)
Notifies the host has processed seams for the cell.
void getBuildCursorSize(int sizes[3]) const
Get the current size of the build cursor.
CCellData * getNextCellToDestroy()
Returns the next cell which its information has to be destroyed by the host.
MapIndex * mapIndex
Current MapIndex object in use.
Definition: ClipmapView.h:394
int totalDownloadCount
Total downloaded cells.
Definition: ClipmapView.h:535
TSet< CCellData * > garbageCells
Set of Cells soon to be disposed unless they are recalled.
Definition: ClipmapView.h:446
BuildCursorMode buildCursorMode
Defines cursor mode 0 - add, 1 - smooth.
Definition: ClipmapView.h:497
int getVoxelOccupancyIndex(int x, int y, int z)
Return the index into the voxel occupancy data for a given x, y, z offset.
Definition: ClipmapView.h:35
double yaw()
Camera rotation over the Y axis.
Definition: ClipmapView.h:577
PaletteType
Type of palette of materials when collecting instances.
void endChanges()
Marks the end of an edition transaction.
CBillboardCache billboardCache
A cache storage for billboards and material instances.
Definition: ClipmapView.h:329
CGenerator * generator
Points to the generator object to be used by the view. This object is able to generate voxel data fro...
Definition: ClipmapView.h:82
CBlockData * blockData
Points to the an object that holds the user data. These are voxels that have been input by the user...
Definition: ClipmapView.h:84
bool invalidateRenderCache
Signal any rendering caching should be invalidated.
Definition: ClipmapView.h:467
void setRemoteView(IRemoteView *remoteView)
Assigns the remote view interface handler.
void updateFillScope()
It updates the fill scope based on the cursor position.
double fillScope[8][3]
It defines the scope for the fill tool. The first 4 points are the starting face for the box and the ...
Definition: ClipmapView.h:515
void clearBoxArea(const double kernel[8][3], bool fullErase)
Clears a box of voxels in the block layer.
double heading
The direction on which the viewer is moving.
Definition: ClipmapView.h:356
CellId cell
cell hit by a collision / ray
Definition: ClipmapView.h:46
TSet< CellId > emptyCells
Set of Cells the engine knows they are empty.
Definition: ClipmapView.h:444
Represents a moving view within a world. Computes new scenes as the view moves.
Definition: ClipmapView.h:65
double slopeDamp
Dampenning to Viewer speed caused by high slope.
Definition: ClipmapView.h:379
double oldSceneXpos
X coordinates for previous Scene.
Definition: ClipmapView.h:412
BuildCursorMode
Build cursor mode.
Definition: ClipmapView.h:29
unsigned char * createVoxelOccupancyData(ContourVoxelData *data)
Creates a leaner data structure to track voxel occupancy. Each voxel is stored in one bit...
The IRemoteView interface allows the clipmap view object to request data for cells. The clipmap view will determine which new cells are required for the next scene and will request them using this interface.
Definition: ClipmapView.h:69
void notifyRemoteCellsChanged(CellId *cells, int count)
Notifies the view some cells have changed.
Scene * oldScene
Previous Scene that was just replaced.
Definition: ClipmapView.h:410
bool resolutionSwitch
Flags a clipmap resolution switch is required.
Definition: ClipmapView.h:333
void repairBlock(LODStats &stats, int buildCursorSize, const int buildCursorSizes[3], const CellId &hitId, const int hitCell[3])
Erases a block at the given edition coordinates.
void hitPosChanged()
Request the system to computes the location of the edition coordinates.
int hitPosYi
Edition point Y coordinate in voxels.
Definition: ClipmapView.h:488
void stampMesh(double worldPos[3], IMeshStampSource *mesh, IMeshStamMaterialSource *materials, const Algebra::Matrix &transform)
It stamps a polygonal mesh into block layer.
void addSmoothBlock()
Adds a smooth block at the current edition coordinates.
int hitPosZi
Edition point Z coordinate in voxels.
Definition: ClipmapView.h:490
void undo()
Reverts the last edition transaction.
Scene * nextScene
The next Scene down the pipeline.
Definition: ClipmapView.h:400
int totalDownloadTime
Total download time.
Definition: ClipmapView.h:537
double time
Time vector (used for animating grass)
Definition: ClipmapView.h:387
bool contourLoop(CGenerator *threadGenerator, ContourThreadContext *tc, CCellData::ThreadContext *tcCellData, LODStats stats)
Performs a contour loop iteration. This will load the voxel data for pending Cells in the requested s...
CCellData * getNextCellToBakeSeams()
Returns the next cell to have its seams processed by the host.
double lineOfSightX1
Line of sight end X coordinate.
Definition: ClipmapView.h:478
void notifyRemoteCellsReady(CellId *cells, int count)
Notifies the view data for some cells is ready.
void beginChanges()
Marks the start of an edition transaction. A call to undo() will restore to this state.
double sceneZpos
Z coordinates for the current scene.
Definition: ClipmapView.h:406
int fillEndDir[3]
Direction of the ending face in only one axis (x, y or z)
Definition: ClipmapView.h:521
int sceneResolution
The current clipmap resolution.
Definition: ClipmapView.h:335
int maxSceneResolution
Desired clipmap resolution.
Definition: ClipmapView.h:337
double sceneXpos
X coordinates for the current scene.
Definition: ClipmapView.h:402
A palette of materials definition for the VoxelFarm.com engine.
void garbageCollect()
Performs garbage collection.
void setLineOfSight(double x0, double y0, double z0, double x1, double y1, double z1)
int scenePendingTotal
Amount of Cells pending processing.
Definition: ClipmapView.h:463
double xpos
Viewer coordinates along the X axis.
Definition: ClipmapView.h:362
Keeps an billboard cache entry for each cell that had its billboards and material instances generated...
Definition: CellData.h:75
CCellData * getNextCellToBake()
Returns the next cell to be processed by the host.
int lastSceneResolution
Previous clipmap resolution.
Definition: ClipmapView.h:339
A Quaternion object.
Definition: Quaternion.h:36
TVector< CCellData * > bakeQueue
List of Cells to be baked.
Definition: ClipmapView.h:440
TSet< CellId > pendingCells
List of Cells int the downloading/generation and processing pipeline.
Definition: ClipmapView.h:442
void notifyCellBaked(CCellData *cellData)
Notifies the host has processed the cell.
double roll()
Camera rotation over the Z axis.
Definition: ClipmapView.h:588
It translates a given material depending of the position in the world.
Definition: StampMesh.h:49