mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Laser rework and Raycasting stuff (#27406)
* basic rays * vector3 tostring * hotfix to exclude origin * altered test method * vector3 minus * actually made raycasthits usable * using raycasthits * renamed test procs file * ups * moved code * forgot * moved vector & procs * reworked 2d-vectors reworked rays to work with 2d-vectors optimized raycast algorithm * reworked raycasting to be costumizable * reworked beams to use ray - first experiment * reworked raycasting to enable control of loop over raycast_hit_check * readability * reworked beams to use new rays TODO: - beam/rebound - ray/is_point - test * vector to angle * progress - TODO angle calculations * progress on rebound * hi damian * fix oops * ray hotfixes TODO: - use clickpos as ray target if possible - move rebound logic to ray_hit_check - graphics * hotfix & deletions * added costum hit_type capability reworked rebound call logic TODO: rebound vector calculation * rebound fix * angle & mirror fix * dumb fuck sadasfhgdasd * start to remove debugging spam * reflection now fully implemented * started work on visualization * damian wants to see * almost done ™️ * progress report - turn wont work, need to write render logic to generate beams * reeeflections * added drawing code * - small tweaks - removed old code - finished visualization * added spawn to let different reflections be drawn independent from each other * removed hitlers * oh shit oh fuck * some small fixes * yeah ok i goofed travis get over it * made dependant code work * dumbfire implemented but not tested cause how * example * remove bench stuff oops * rewrote raycast hit code to allow more possible modifications * added original check * original_check hotfixes * actual hotfix... * mirror fix * original_check hotfix * unit tests * to_bump hotfix * to_bump hotfix * misc fixes * reworked collision physics * big nono * finishing collision physics * fixes for sonix * tgstation ™️ * removed old unit-test * unit test fixes * damian actually reviewed Co-authored-by: Damian <damian@autistici.org>
This commit is contained in:
@@ -12,4 +12,6 @@
|
||||
#include "turretid.dm"
|
||||
#include "lazy_events.dm"
|
||||
#include "outfit_datums.dm"
|
||||
#endif
|
||||
#include "ray.dm"
|
||||
#include "vector.dm"
|
||||
#endif
|
||||
|
||||
38
code/modules/unit_tests/ray.dm
Normal file
38
code/modules/unit_tests/ray.dm
Normal file
@@ -0,0 +1,38 @@
|
||||
/datum/unit_test/ray_equals/start()
|
||||
var/vector/origin = new /vector(0,3)
|
||||
var/vector/direction = new /vector(4,7)
|
||||
var/ray/R1 = new /ray(origin, direction)
|
||||
var/ray/R2 = new /ray(origin, direction)
|
||||
if(!R1.equals(R2))
|
||||
fail("Rays not equal")
|
||||
|
||||
/datum/unit_test/ray_overlaps/start()
|
||||
var/vector/origin = new /vector(0,3)
|
||||
var/vector/direction = new /vector(4,7)
|
||||
var/ray/R1 = new /ray(origin, direction)
|
||||
var/ray/R2 = new /ray(origin, direction)
|
||||
if(!R1.overlaps(R2))
|
||||
fail("Rays #1 not overlapping")
|
||||
|
||||
direction = new /vector(-4,-7)
|
||||
R1 = new /ray(origin, direction)
|
||||
R2 = new /ray(origin, direction)
|
||||
if(!R1.equals(R2))
|
||||
fail("Rays #2 not overlapping")
|
||||
|
||||
/datum/unit_test/ray_hitsPoint/start()
|
||||
var/vector/origin = new /vector(0,3)
|
||||
var/vector/direction = new /vector(2,10)
|
||||
var/vector/P = new /vector(1,8)
|
||||
var/ray/R = new /ray(origin, direction)
|
||||
if(!R.hitsPoint(P))
|
||||
fail("Ray not hitting point")
|
||||
|
||||
/datum/unit_test/ray_getPoint/start()
|
||||
var/vector/origin = new /vector(0,3)
|
||||
var/vector/direction = new /vector(4,10)
|
||||
var/distance = 0.5
|
||||
var/vector/P = new /vector(0.2,3.5)
|
||||
var/ray/R = new /ray(origin, direction)
|
||||
if(!R.getPoint(distance).equals(P))
|
||||
fail("Ray returned invalid point "+R.getPoint(distance).toString())
|
||||
57
code/modules/unit_tests/vector.dm
Normal file
57
code/modules/unit_tests/vector.dm
Normal file
@@ -0,0 +1,57 @@
|
||||
/datum/unit_test/vector_duplicate/start()
|
||||
var/vector/V
|
||||
var/vector/D
|
||||
for(var/i in range(100))
|
||||
V = new /vector(i, i*2)
|
||||
D = V.duplicate()
|
||||
if(D == V)
|
||||
fail("Reference copied")
|
||||
|
||||
if(D.x != V.x || D.y != V.y)
|
||||
fail("Value mismatch")
|
||||
|
||||
/datum/unit_test/vector_isnull/start()
|
||||
var/vector/V = new /vector(0,0.0)
|
||||
if(!V.is_null())
|
||||
fail("Vector not null")
|
||||
|
||||
/datum/unit_test/vector_isint/start()
|
||||
var/vector/V = new /vector(5416,115)
|
||||
if(!V.is_integer())
|
||||
fail("Vector not int, should be int")
|
||||
|
||||
V = new /vector(5416.044,115)
|
||||
if(V.is_integer())
|
||||
fail("Vector int, should not be int")
|
||||
|
||||
/datum/unit_test/vector_toangle/start()
|
||||
var/vector/V = new /vector(1,1)
|
||||
var/angle = V.toAngle()
|
||||
if(angle != 45)
|
||||
fail("Angle #1 ("+num2text(angle)+") incorrect")
|
||||
|
||||
V = new /vector(-1,1)
|
||||
angle = V.toAngle()
|
||||
if(angle != 315)
|
||||
fail("Angle #2 ("+num2text(angle)+") incorrect")
|
||||
|
||||
/datum/unit_test/vector_mirror/start()
|
||||
var/vector/V = new /vector(1,-1)
|
||||
var/vector/N = new /vector(0,1)
|
||||
var/vector/M = new /vector(1,1)
|
||||
var/vector/R = V.mirrorWithNormal(N)
|
||||
if(!R.equals(M))
|
||||
fail("Mirror #2 incorrect "+R.toString())
|
||||
|
||||
/datum/unit_test/vector_dot/start()
|
||||
var/vector/V1 = new /vector(4,-1)
|
||||
var/vector/V2 = new /vector(1,1)
|
||||
var/d = V1.dot(V2)
|
||||
if(d != 3)
|
||||
fail("Dot product #1 ("+num2text(d)+") incorrect")
|
||||
|
||||
V1 = new /vector(0,2)
|
||||
V2 = new /vector(1,1)
|
||||
d = V1.dot(V2)
|
||||
if(d != 2)
|
||||
fail("Dot product #2 ("+num2text(d)+") incorrect")
|
||||
Reference in New Issue
Block a user