aboutsummaryrefslogtreecommitdiff
Commit message (Expand)AuthorAge
...
* Client crashfix: load meta after digging (#5801)Paramat2017-05-23
* LINT fix & check all files with clang-formatLoic Blot2017-05-22
* [CSM] Add send_chat_message and run_server_chatcommand API functions (#5747)Pierre-Adrien Langrognet2017-05-21
* Run updatepo.shLoic Blot2017-05-21
* Translated using Weblate (Ukrainian)Fixer2017-05-21
* Translated using Weblate (Russian)weqqr2017-05-21
* Translated using Weblate (Chinese (Simplified))Gaunthan Huang2017-05-21
* Translated using Weblate (Turkish)monolifed2017-05-21
* Translated using Weblate (Spanish)Michael Higuera2017-05-21
* Translated using Weblate (Malay)Muhammad Nur Hidayat Yasuyoshi2017-05-21
* Translated using Weblate (Esperanto)yellowcrash102017-05-21
* Added translation using Weblate (Dhivehi)Unknown2017-05-21
* Translated using Weblate (Spanish)Erick Sanhueza2017-05-21
* Fix LINT broken by dfa0c15ce045705f05487d623dc7beca6c945b4bLoic Blot2017-05-21
* [CSM] Add function to get the definition of items (#5732)bigfoot5472017-05-21
* Prevent fall damage from overflowing when falling from a large height. (#5791)red-0012017-05-21
* Menu: Merge singleplayer and server tabs (#5627)Elijah Duffy2017-05-21
* Add clientmods/mods.conf & client/mod_storage to gitignoreLoic Blot2017-05-21
* [CSM] Allow enabling and disabling mods. (#5554)red-0012017-05-21
* Real control fix (#5787)Loïc Blot2017-05-20
* Fix instant digging (#5785)you2017-05-20
* Fix wchar_t type on 605599b6f150b89ba6539c4d088231b326adcb48Loic Blot2017-05-20
* Particle spawner: Do not spawn particles distant from player (#5766)Paramat2017-05-20
* [CSM] Correct the log destination of print() (#5784)SmallJoker2017-05-20
* Fix CSM crash (#5779)red-0012017-05-20
* Typo fix in README.txtLoic Blot2017-05-20
* Add /clearinv chat command (#4994)Elijah Duffy2017-05-20
* chat.cpp fix wchar_t isspace -> iswspace & wrong isspace on an index (#5783)Loïc Blot2017-05-20
* Cleanup in content_mapblock (#5746)numberZero2017-05-20
* Improve password change menu (#5757)red-0012017-05-20
* Fix shift key producing space in console (#5777)Craig Davison2017-05-20
* this might fix #5661, needs testing (#5775)red-0012017-05-20
* [CSM] Fix crash when the minimap is disabled. Caused by e25a38eSmallJoker2017-05-20
* Fix input regression introduced by a4a377ecad6f1732cc54e7ac329fdef9949f9bf7Loic Blot2017-05-20
* Fix mem leak in mesh cache (#5781)Zeno-2017-05-20
* Various code cleanup & little performance improvement on HTTP download (#5772)Loïc Blot2017-05-20
* Do not create dummy normalmaps (#4180)you2017-05-19
* Fix textarea bug: clicking right of the end of a line caused the cursor to be...you2017-05-19
* Fix alpha for liquid nodes (#5494)Dániel Juhász2017-05-19
* Mainmenu: Fix issues while trying to enable all mods (#5770)SmallJoker2017-05-19
* When minimap is disabled in configuration, really disable it (#5771)Loïc Blot2017-05-19
* Fix a warning pointed by GCC 7.1Loic Blot2017-05-18
* Builtin: Fix subgame mod selection (#5367)SmallJoker2017-05-17
* Particles: Do not send single particles to distant clients (#5760)Paramat2017-05-17
* Append -debug to version string (#5765)bigfoot5472017-05-17
* CSM: Document forgotten functionsSmallJoker2017-05-16
* Caverns: Remove unnecessary liquid excavationparamat2017-05-16
* Fix a memleak pointed by @Zeno- in MeshUpdateQueueLoic Blot2017-05-16
* Fix uninitalised variable in event.cpp (#5764)Zeno-2017-05-15
* Add option to use neither node highlighting nor outliningezhh2017-05-15
= math.floor(v.x + 0.5), y = math.floor(v.y + 0.5), z = math.floor(v.z + 0.5) } end function vector.apply(v, func) return { x = func(v.x), y = func(v.y), z = func(v.z) } end function vector.distance(a, b) local x = a.x - b.x local y = a.y - b.y local z = a.z - b.z return math.hypot(x, math.hypot(y, z)) end function vector.direction(pos1, pos2) return vector.normalize({ x = pos2.x - pos1.x, y = pos2.y - pos1.y, z = pos2.z - pos1.z }) end function vector.angle(a, b) local dotp = vector.dot(a, b) local cp = vector.cross(a, b) local crossplen = vector.length(cp) return math.atan2(crossplen, dotp) end function vector.dot(a, b) return a.x * b.x + a.y * b.y + a.z * b.z end function vector.cross(a, b) return { x = a.y * b.z - a.z * b.y, y = a.z * b.x - a.x * b.z, z = a.x * b.y - a.y * b.x } end function vector.add(a, b) if type(b) == "table" then return {x = a.x + b.x, y = a.y + b.y, z = a.z + b.z} else return {x = a.x + b, y = a.y + b, z = a.z + b} end end function vector.subtract(a, b) if type(b) == "table" then return {x = a.x - b.x, y = a.y - b.y, z = a.z - b.z} else return {x = a.x - b, y = a.y - b, z = a.z - b} end end function vector.multiply(a, b) if type(b) == "table" then return {x = a.x * b.x, y = a.y * b.y, z = a.z * b.z} else return {x = a.x * b, y = a.y * b, z = a.z * b} end end function vector.divide(a, b) if type(b) == "table" then return {x = a.x / b.x, y = a.y / b.y, z = a.z / b.z} else return {x = a.x / b, y = a.y / b, z = a.z / b} end end function vector.offset(v, x, y, z) return {x = v.x + x, y = v.y + y, z = v.z + z} end function vector.sort(a, b) return {x = math.min(a.x, b.x), y = math.min(a.y, b.y), z = math.min(a.z, b.z)}, {x = math.max(a.x, b.x), y = math.max(a.y, b.y), z = math.max(a.z, b.z)} end local function sin(x) if x % math.pi == 0 then return 0 else return math.sin(x) end end local function cos(x) if x % math.pi == math.pi / 2 then return 0 else return math.cos(x) end end function vector.rotate_around_axis(v, axis, angle) local cosangle = cos(angle) local sinangle = sin(angle) axis = vector.normalize(axis) -- https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula local dot_axis = vector.multiply(axis, vector.dot(axis, v)) local cross = vector.cross(v, axis) return vector.new( cross.x * sinangle + (v.x - dot_axis.x) * cosangle + dot_axis.x, cross.y * sinangle + (v.y - dot_axis.y) * cosangle + dot_axis.y, cross.z * sinangle + (v.z - dot_axis.z) * cosangle + dot_axis.z ) end function vector.rotate(v, rot) local sinpitch = sin(-rot.x) local sinyaw = sin(-rot.y) local sinroll = sin(-rot.z) local cospitch = cos(rot.x) local cosyaw = cos(rot.y) local cosroll = math.cos(rot.z) -- Rotation matrix that applies yaw, pitch and roll local matrix = { { sinyaw * sinpitch * sinroll + cosyaw * cosroll, sinyaw * sinpitch * cosroll - cosyaw * sinroll, sinyaw * cospitch, }, { cospitch * sinroll, cospitch * cosroll, -sinpitch, }, { cosyaw * sinpitch * sinroll - sinyaw * cosroll, cosyaw * sinpitch * cosroll + sinyaw * sinroll, cosyaw * cospitch, }, } -- Compute matrix multiplication: `matrix` * `v` return vector.new( matrix[1][1] * v.x + matrix[1][2] * v.y + matrix[1][3] * v.z, matrix[2][1] * v.x + matrix[2][2] * v.y + matrix[2][3] * v.z, matrix[3][1] * v.x + matrix[3][2] * v.y + matrix[3][3] * v.z ) end function vector.dir_to_rotation(forward, up) forward = vector.normalize(forward) local rot = {x = math.asin(forward.y), y = -math.atan2(forward.x, forward.z), z = 0} if not up then return rot end assert(vector.dot(forward, up) < 0.000001, "Invalid vectors passed to vector.dir_to_rotation().") up = vector.normalize(up) -- Calculate vector pointing up with roll = 0, just based on forward vector. local forwup = vector.rotate({x = 0, y = 1, z = 0}, rot) -- 'forwup' and 'up' are now in a plane with 'forward' as normal. -- The angle between them is the absolute of the roll value we're looking for. rot.z = vector.angle(forwup, up) -- Since vector.angle never returns a negative value or a value greater -- than math.pi, rot.z has to be inverted sometimes. -- To determine wether this is the case, we rotate the up vector back around -- the forward vector and check if it worked out. local back = vector.rotate_around_axis(up, forward, -rot.z) -- We don't use vector.equals for this because of floating point imprecision. if (back.x - forwup.x) * (back.x - forwup.x) + (back.y - forwup.y) * (back.y - forwup.y) + (back.z - forwup.z) * (back.z - forwup.z) > 0.0000001 then rot.z = -rot.z end return rot end