aboutsummaryrefslogtreecommitdiff
path: root/src/camera.h
Commit message (Collapse)AuthorAge
* Replace std::list to std::vector into tile.cpp (m_texture_trash) and move ↵Loic Blot2015-03-05
| | | | tile.hpp to src/client/
* Fix regression (increase/decrease viewing range with +/- keys)Craig Robbins2014-12-07
|
* Performance of main client loop up to 2x faster In places, up to 3 times fasterCraig Robbins2014-12-07
| | | | | NOTE 1: This does not mean a 2x increase in framerate. Increase in fps may be up to 1-2fps NOTE 2: This local 'caching' of settings is not optimal and an alternative solution will be worked on after 0.4.11 is released
* Implement WieldMeshSceneNode which improves wield mesh renderingKahrl2014-11-08
| | | | | | | | | | | | | - Don't create and cache an extruded mesh for every (non-node) item. Instead use a single one per image resolution. - For cubic nodes reuse a single wield mesh too - Improve lighting of the wielded item - Increase far value of wield mesh scene camera, fixes #1770 - Also includes some minor refactorings of Camera and GenericCAO.
* Add support for interlaced polarized 3d screenssapier2014-05-18
| | | | Add (experimental) support for topbottom as well as sidebyside 3d mode
* Add support for dpi based HUD scalingsapier2014-04-27
| | | | | | Add support for (configurable) multiline hotbar Improved screensize handling Add userdefined gui scale by BlockMen
* Fix all warnings reported by clangSfan52014-04-15
|
* Add player:set_eye_offset() by @MirceaKitsune and clean upBlockMen2014-04-12
|
* Add third person viewBlockMen2014-04-12
|
* Fix rendering glitches when far from the center of the mapNovatux2014-03-04
|
* Fix and improve view range tunerPerttu Ahola2013-08-03
|
* Add a little animation when changing the wielded itemPilzAdam2013-05-20
|
* Swing the camera down when the player lands on the ground, based on the ↵MirceaKitsune2013-04-11
| | | | velocity the surface is hit with.
* fix mesh leak in camera classsapier2013-04-07
|
* Update Copyright YearsSfan52013-02-24
|
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
|
* Optimize headersPerttu Ahola2012-06-17
|
* Properly and efficiently use split utility headersPerttu Ahola2012-06-17
|
* Switch the license to be LGPLv2/later, with small parts still remaining as ↵Perttu Ahola2012-06-05
| | | | GPLv2/later, by agreement of major contributors
* c55sound continuedPerttu Ahola2012-03-24
|
* Fix and tune things, add tool "recharge" animation, add dummyballPerttu Ahola2012-03-10
|
* Page up and down change the minimum viewing rangeKahrl2012-02-01
|
* The huge item definition and item namespace unification patch (itemdef), see ↵Kahrl2012-01-12
| | | | http://c55.me/minetest/wiki/doku.php?id=changes:itemdef
* inventorycube: use all three specified textures; also moved mesh creation / ↵Kahrl2011-12-03
| | | | modification functions to mesh.cpp; in lua, inventorycube is now called minetest.inventorycube
* Fix structs being declared as classesGiuseppe Bilotta2011-12-01
| | | | | | Some compilers complain when a class is declared as a struct or vice versa. Fix by making sure that the correct tag is used both in declaration and definition.
* GameDef compilesPerttu Ahola2011-11-29
|
* Create framework for getting rid of global definitions of ↵Perttu Ahola2011-11-29
| | | | node/tool/item/whatever types
* Header file tweaking; mainly for speedPerttu Ahola2011-10-12
|
* Simplistic wielded tool lighting, added setMeshVerticesColor to utility.h ↵Kahrl2011-09-21
| | | | and refactored some other code into calls of that
* Create a separate scene manager for the wielded tool. This fixes the ↵Kahrl2011-09-21
| | | | glitchyness in large map coordinates and some depth buffer problems. (The tool doesn't bob anymore when walking, this will be fixed later.) Fix MSVC build (thanks to dannydark).
* Digging animationKahrl2011-09-20
|
* Wielded tool updates, leaves and glass work nowKahrl2011-09-19
|
* Convert any inventory item into a mesh, bring back ↵Kahrl2011-09-19
| | | | InventoryItem::getImageRay(), some const-correctness fixes
* Added sprite extruderKahrl2011-09-19
|
* This looks more like MC view bobbing, but still not even closeKahrl2011-09-18
|
* Made wielded tool move slightly (and smoothly) during view bobbing. Making ↵Kahrl2011-09-15
| | | | the tool be a child node of an empty scene node instead of the camera scene node seemingly fixed the uncontrollable tool jitter, too.
* View bobbing is slower in the water.Kahrl2011-09-15
|
* Implemented view bobbing (testing simple lemniscate shape)Kahrl2011-09-08
|
* Collected and moved existing camera infrastructure from game.cpp to ↵Kahrl2011-09-08
camera.cpp and camera.h. Introduced configuration settings 'fov' which chooses the camera's (vertical) field of view and 'view_bobbing' which currently does nothing. Other code refactored to not expect the FOV to be a build time constant.
e <list> #include <map> class INodeDefManager; // For VC++ #undef min #undef max /* A fast voxel manipulator class. In normal operation, it fetches more map when it is requested. It can also be used so that all allowed area is fetched at the start, using ManualMapVoxelManipulator. Not thread-safe. */ /* Debug stuff */ extern u32 emerge_time; extern u32 emerge_load_time; /* This class resembles aabbox3d<s16> a lot, but has inclusive edges for saner handling of integer sizes */ class VoxelArea { public: // Starts as zero sized VoxelArea(): MinEdge(1,1,1), MaxEdge(0,0,0) { } VoxelArea(v3s16 min_edge, v3s16 max_edge): MinEdge(min_edge), MaxEdge(max_edge) { } VoxelArea(v3s16 p): MinEdge(p), MaxEdge(p) { } /* Modifying methods */ void addArea(const VoxelArea &a) { if (hasEmptyExtent()) { *this = a; return; } if(a.MinEdge.X < MinEdge.X) MinEdge.X = a.MinEdge.X; if(a.MinEdge.Y < MinEdge.Y) MinEdge.Y = a.MinEdge.Y; if(a.MinEdge.Z < MinEdge.Z) MinEdge.Z = a.MinEdge.Z; if(a.MaxEdge.X > MaxEdge.X) MaxEdge.X = a.MaxEdge.X; if(a.MaxEdge.Y > MaxEdge.Y) MaxEdge.Y = a.MaxEdge.Y; if(a.MaxEdge.Z > MaxEdge.Z) MaxEdge.Z = a.MaxEdge.Z; } void addPoint(const v3s16 &p) { if(hasEmptyExtent()) { MinEdge = p; MaxEdge = p; return; } if(p.X < MinEdge.X) MinEdge.X = p.X; if(p.Y < MinEdge.Y) MinEdge.Y = p.Y; if(p.Z < MinEdge.Z) MinEdge.Z = p.Z; if(p.X > MaxEdge.X) MaxEdge.X = p.X; if(p.Y > MaxEdge.Y) MaxEdge.Y = p.Y; if(p.Z > MaxEdge.Z) MaxEdge.Z = p.Z; } // Pad with d nodes void pad(const v3s16 &d) { MinEdge -= d; MaxEdge += d; } /*void operator+=(v3s16 off) { MinEdge += off; MaxEdge += off; } void operator-=(v3s16 off) { MinEdge -= off; MaxEdge -= off; }*/ /* const methods */ v3s16 getExtent() const { return MaxEdge - MinEdge + v3s16(1,1,1); } /* Because MaxEdge and MinEdge are included in the voxel area an empty extent * is not represented by (0, 0, 0), but instead (-1, -1, -1) */ bool hasEmptyExtent() const { return MaxEdge - MinEdge == v3s16(-1, -1, -1); } s32 getVolume() const { v3s16 e = getExtent(); return (s32)e.X * (s32)e.Y * (s32)e.Z; } bool contains(const VoxelArea &a) const { // No area contains an empty area // NOTE: Algorithms depend on this, so do not change. if(a.hasEmptyExtent()) return false; return( a.MinEdge.X >= MinEdge.X && a.MaxEdge.X <= MaxEdge.X && a.MinEdge.Y >= MinEdge.Y && a.MaxEdge.Y <= MaxEdge.Y && a.MinEdge.Z >= MinEdge.Z && a.MaxEdge.Z <= MaxEdge.Z ); } bool contains(v3s16 p) const { return( p.X >= MinEdge.X && p.X <= MaxEdge.X && p.Y >= MinEdge.Y && p.Y <= MaxEdge.Y && p.Z >= MinEdge.Z && p.Z <= MaxEdge.Z ); } bool contains(s32 i) const { return (i >= 0 && i < getVolume()); } bool operator==(const VoxelArea &other) const { return (MinEdge == other.MinEdge && MaxEdge == other.MaxEdge); } VoxelArea operator+(v3s16 off) const { return VoxelArea(MinEdge+off, MaxEdge+off); } VoxelArea operator-(v3s16 off) const { return VoxelArea(MinEdge-off, MaxEdge-off); } /* Returns 0-6 non-overlapping areas that can be added to a to make up this area. a: area inside *this */ void diff(const VoxelArea &a, std::list<VoxelArea> &result) { /* This can result in a maximum of 6 areas */ // If a is an empty area, return the current area as a whole if(a.getExtent() == v3s16(0,0,0)) { VoxelArea b = *this; if(b.getVolume() != 0) result.push_back(b); return; } assert(contains(a)); // pre-condition // Take back area, XY inclusive { v3s16 min(MinEdge.X, MinEdge.Y, a.MaxEdge.Z+1); v3s16 max(MaxEdge.X, MaxEdge.Y, MaxEdge.Z); VoxelArea b(min, max); if(b.getVolume() != 0) result.push_back(b); } // Take front area, XY inclusive { v3s16 min(MinEdge.X, MinEdge.Y, MinEdge.Z); v3s16 max(MaxEdge.X, MaxEdge.Y, a.MinEdge.Z-1); VoxelArea b(min, max); if(b.getVolume() != 0) result.push_back(b); } // Take top area, X inclusive { v3s16 min(MinEdge.X, a.MaxEdge.Y+1, a.MinEdge.Z); v3s16 max(MaxEdge.X, MaxEdge.Y, a.MaxEdge.Z); VoxelArea b(min, max); if(b.getVolume() != 0) result.push_back(b); } // Take bottom area, X inclusive { v3s16 min(MinEdge.X, MinEdge.Y, a.MinEdge.Z); v3s16 max(MaxEdge.X, a.MinEdge.Y-1, a.MaxEdge.Z); VoxelArea b(min, max); if(b.getVolume() != 0) result.push_back(b); } // Take left area, non-inclusive { v3s16 min(MinEdge.X, a.MinEdge.Y, a.MinEdge.Z); v3s16 max(a.MinEdge.X-1, a.MaxEdge.Y, a.MaxEdge.Z); VoxelArea b(min, max); if(b.getVolume() != 0) result.push_back(b); } // Take right area, non-inclusive { v3s16 min(a.MaxEdge.X+1, a.MinEdge.Y, a.MinEdge.Z); v3s16 max(MaxEdge.X, a.MaxEdge.Y, a.MaxEdge.Z); VoxelArea b(min, max); if(b.getVolume() != 0) result.push_back(b); } } /* Translates position from virtual coordinates to array index */ s32 index(s16 x, s16 y, s16 z) const { v3s16 em = getExtent(); v3s16 off = MinEdge; s32 i = (s32)(z-off.Z)*em.Y*em.X + (y-off.Y)*em.X + (x-off.X); //dstream<<" i("<<x<<","<<y<<","<<z<<")="<<i<<" "; return i; } s32 index(v3s16 p) const { return index(p.X, p.Y, p.Z); } // Translate index in the X coordinate void add_x(const v3s16 &extent, u32 &i, s16 a) { i += a; } // Translate index in the Y coordinate void add_y(const v3s16 &extent, u32 &i, s16 a) { i += a * extent.X; } // Translate index in the Z coordinate void add_z(const v3s16 &extent, u32 &i, s16 a) { i += a * extent.X*extent.Y; } // Translate index in space void add_p(const v3s16 &extent, u32 &i, v3s16 a) { i += a.Z*extent.X*extent.Y + a.Y*extent.X + a.X; } /* Print method for debugging */ void print(std::ostream &o) const { v3s16 e = getExtent(); o<<"("<<MinEdge.X <<","<<MinEdge.Y <<","<<MinEdge.Z <<")("<<MaxEdge.X <<","<<MaxEdge.Y <<","<<MaxEdge.Z <<")" <<"="<<e.X<<"x"<<e.Y<<"x"<<e.Z<<"="<<getVolume(); } // Edges are inclusive v3s16 MinEdge; v3s16 MaxEdge; }; // unused #define VOXELFLAG_UNUSED (1<<0) // no data about that node #define VOXELFLAG_NO_DATA (1<<1) // Algorithm-dependent #define VOXELFLAG_CHECKED1 (1<<2) // Algorithm-dependent #define VOXELFLAG_CHECKED2 (1<<3) // Algorithm-dependent #define VOXELFLAG_CHECKED3 (1<<4) // Algorithm-dependent #define VOXELFLAG_CHECKED4 (1<<5) enum VoxelPrintMode { VOXELPRINT_NOTHING, VOXELPRINT_MATERIAL, VOXELPRINT_WATERPRESSURE, VOXELPRINT_LIGHT_DAY, }; class VoxelManipulator /*: public NodeContainer*/ { public: VoxelManipulator(); virtual ~VoxelManipulator(); /* Virtuals from NodeContainer */ /*virtual u16 nodeContainerId() const { return NODECONTAINER_ID_VOXELMANIPULATOR; } bool isValidPosition(v3s16 p) { addArea(p); return !(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA); }*/ /* These are a bit slow and shouldn't be used internally. Use m_data[m_area.index(p)] instead. */ MapNode getNode(v3s16 p) { VoxelArea voxel_area(p); addArea(voxel_area); if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA) { /*dstream<<"EXCEPT: VoxelManipulator::getNode(): " <<"p=("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<", index="<<m_area.index(p) <<", flags="<<(int)m_flags[m_area.index(p)] <<" is inexistent"<<std::endl;*/ throw InvalidPositionException ("VoxelManipulator: getNode: inexistent"); } return m_data[m_area.index(p)]; } MapNode getNodeNoEx(v3s16 p) { VoxelArea voxel_area(p); addArea(voxel_area); if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA) { return MapNode(CONTENT_IGNORE); } return m_data[m_area.index(p)]; } MapNode getNodeNoExNoEmerge(v3s16 p) { if(m_area.contains(p) == false) return MapNode(CONTENT_IGNORE); if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA) return MapNode(CONTENT_IGNORE); return m_data[m_area.index(p)]; } // Stuff explodes if non-emerged area is touched with this. // Emerge first, and check VOXELFLAG_NO_DATA if appropriate. MapNode & getNodeRefUnsafe(const v3s16 &p) { return m_data[m_area.index(p)]; } const MapNode & getNodeRefUnsafeCheckFlags(const v3s16 &p) { s32 index = m_area.index(p); if (m_flags[index] & VOXELFLAG_NO_DATA) return ContentIgnoreNode; return m_data[index]; } u8 & getFlagsRefUnsafe(v3s16 p) { return m_flags[m_area.index(p)]; } bool exists(v3s16 p) { return m_area.contains(p) && !(getFlagsRefUnsafe(p) & VOXELFLAG_NO_DATA); } MapNode & getNodeRef(v3s16 p) { VoxelArea voxel_area(p); addArea(voxel_area); if(getFlagsRefUnsafe(p) & VOXELFLAG_NO_DATA) { /*dstream<<"EXCEPT: VoxelManipulator::getNode(): " <<"p=("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<", index="<<m_area.index(p) <<", flags="<<(int)getFlagsRefUnsafe(p) <<" is inexistent"<<std::endl;*/ throw InvalidPositionException ("VoxelManipulator: getNode: inexistent"); } return getNodeRefUnsafe(p); } void setNode(v3s16 p, const MapNode &n) { VoxelArea voxel_area(p); addArea(voxel_area); m_data[m_area.index(p)] = n; m_flags[m_area.index(p)] &= ~VOXELFLAG_NO_DATA; } // TODO: Should be removed and replaced with setNode void setNodeNoRef(v3s16 p, const MapNode &n) { setNode(p, n); } /*void setExists(VoxelArea a) { addArea(a); for(s32 z=a.MinEdge.Z; z<=a.MaxEdge.Z; z++) for(s32 y=a.MinEdge.Y; y<=a.MaxEdge.Y; y++) for(s32 x=a.MinEdge.X; x<=a.MaxEdge.X; x++) { m_flags[m_area.index(x,y,z)] &= ~VOXELFLAG_NO_DATA; } }*/ /*MapNode & operator[](v3s16 p) { //dstream<<"operator[] p=("<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl; if(isValidPosition(p) == false) addArea(VoxelArea(p)); return m_data[m_area.index(p)]; }*/ /* Set stuff if available without an emerge. Return false if failed. This is convenient but slower than playing around directly with the m_data table with indices. */ bool setNodeNoEmerge(v3s16 p, MapNode n) { if(m_area.contains(p) == false) return false; m_data[m_area.index(p)] = n; return true; } bool setNodeNoEmerge(s32 i, MapNode n) { if(m_area.contains(i) == false) return false; m_data[i] = n; return true; } /*bool setContentNoEmerge(v3s16 p, u8 c) { if(isValidPosition(p) == false) return false; m_data[m_area.index(p)].d = c; }*/ /* Control */ virtual void clear(); void print(std::ostream &o, INodeDefManager *nodemgr, VoxelPrintMode mode=VOXELPRINT_MATERIAL); void addArea(const VoxelArea &area); /* Copy data and set flags to 0 dst_area.getExtent() <= src_area.getExtent() */ void copyFrom(MapNode *src, const VoxelArea& src_area, v3s16 from_pos, v3s16 to_pos, v3s16 size); // Copy data void copyTo(MapNode *dst, const VoxelArea& dst_area, v3s16 dst_pos, v3s16 from_pos, v3s16 size); /* Algorithms */ void clearFlag(u8 flag); // TODO: Move to voxelalgorithms.h void unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight, std::set<v3s16> & light_sources, INodeDefManager *nodemgr); void unspreadLight(enum LightBank bank, std::map<v3s16, u8> & from_nodes, std::set<v3s16> & light_sources, INodeDefManager *nodemgr); void spreadLight(enum LightBank bank, v3s16 p, INodeDefManager *nodemgr); void spreadLight(enum LightBank bank, std::set<v3s16> & from_nodes, INodeDefManager *nodemgr); /* Virtual functions */ /* Member variables */ /* The area that is stored in m_data. addInternalBox should not be used if getExtent() == v3s16(0,0,0) MaxEdge is 1 higher than maximum allowed position */ VoxelArea m_area; /* NULL if data size is 0 (extent (0,0,0)) Data is stored as [z*h*w + y*h + x] */ MapNode *m_data; /* Flags of all nodes */ u8 *m_flags; static const MapNode ContentIgnoreNode; //TODO: Use these or remove them //TODO: Would these make any speed improvement? //bool m_pressure_route_valid; //v3s16 m_pressure_route_surface; /* Some settings */ //bool m_disable_water_climb; private: }; #endif