micro-optimizations
This commit is contained in:
		| @@ -22,28 +22,26 @@ function collides() | ||||
| 	 | ||||
| 	-- x | ||||
| 	if ldx==0 then | ||||
| 		local lx=lx0 -- which ==lx1 | ||||
| 		if (lx<bx0 or lx>=bx1) return nil | ||||
| 		if (lx0<bx0 or lx0>bx1) return | ||||
| 	else | ||||
|  	local tx0=(bx0-lx0)/ldx | ||||
|  	local tx1=(bx1-lx0)/ldx | ||||
|  	 | ||||
|  	tmin=max(tmin,min(tx0,tx1)) | ||||
|  	tmax=min(tmax,max(tx0,tx1)) | ||||
|  	if (tx0 > tx1) tx0,tx1=tx1,tx0 | ||||
|  	if (tmin < tx0) tmin=tx0 | ||||
|  	if (tmax > tx1) tmax=tx1 | ||||
|  end | ||||
|   | ||||
| 	if ldy==0 then | ||||
| 		local ly=ly0 -- which ==ly1 | ||||
| 		if (ly<by0 or ly>=by1) return nil | ||||
| 		if (ly0<by0 or ly0>by1) return | ||||
| 	else | ||||
|  	local ty0=(by0-ly0)/ldy | ||||
|  	local ty1=(by1-ly0)/ldy | ||||
|  	 | ||||
|  	tmin=max(tmin,min(ty0,ty1)) | ||||
|  	tmax=min(tmax,max(ty0,ty1)) | ||||
|  	if (ty0 > ty1) ty0,ty1=ty1,ty0 | ||||
|  	if (tmin < ty0) tmin=ty0 | ||||
|  	if (tmax > ty1) tmax=ty1 | ||||
|  end  | ||||
|   | ||||
|  if (tmax < tmin) return nil | ||||
|  if (tmax < tmin) return | ||||
|  return tmin,tmax | ||||
| end | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user