This commit is contained in:
shadowscion 2022-07-28 19:04:46 -05:00
parent b543651d1d
commit fa43a95bf5
3 changed files with 127 additions and 2 deletions

View File

@ -604,6 +604,28 @@ do
end
--[[
@FUNCTION: simpleton:CopyVertex
@DESCRIPTION: Copy an existing vertex and add it to the vertex table
@PARAMETERS:
[number] n -- the existing vertex index
[number] x -- optional setter
[number] y -- optional setter
[number] z -- optional setter
@RETURN:
[number] -- the index of the added vertex
--]]
function meta:CopyVertex( n, x, y, z )
local copy = self.verts[n]
if not copy then return end
self.verts[#self.verts + 1] = Vector( x or copy.x, y or copy.y, z or copy.z )
return #self.verts
end
--[[
@FUNCTION: simpleton:PushXYZ
@ -2638,8 +2660,8 @@ registerType( "rail_slider", function( param, data, threaded, physics )
-- flange
local fbits, getflange = math_floor( tonumber( param.PrimFENUMS ) or 0 )
local ENUM_FENABLE = 1
if bit.band( fbits, ENUM_FENABLE ) == ENUM_FENABLE then
local ENUM_FENABLE = bit.bor( 1, 2, 4, 8 )
if bit.band( fbits, ENUM_FENABLE ) ~= 0 then
local fdim
if double then
fdim = Vector( cdim.x, cgap - cdim.y, cdim.z * 0.25 )
@ -2691,3 +2713,89 @@ registerType( "rail_slider", function( param, data, threaded, physics )
return model
end )
-- STAIRCASE
registerType( "staircase", function( param, data, threaded, physics )
local count = math_clamp( math_floor( tonumber( param.PrimSCOUNT ) or 0 ), 1, 32 )
local rise = math_clamp( tonumber( param.PrimSRISE ) or 0, 1, 48 )
local run = math_clamp( tonumber( param.PrimSRUN ) or 0, 1, 48 )
local width = math_clamp( ( tonumber( param.PrimSWIDTH ) or 0 ) * 0.5, 1, 1000 )
local model = simpleton.New()
local verts = model.verts
if physics then
model.convexes = {}
end
for i = 0, count - 1 do
local a = model:PushXYZ( run * i, width, rise * i )
local b = model:PushXYZ( run * i, width, rise * i + rise )
local c = model:PushXYZ( run * i + run, width, rise * i + rise )
local d = model:CopyVertex( a, nil, -width, nil )
local e = model:CopyVertex( b, nil, -width, nil )
local f = model:CopyVertex( c, nil, -width, nil )
if physics then
model.convexes[#model.convexes + 1] = {
verts[a],
verts[b],
verts[c],
verts[d],
verts[e],
verts[f],
}
end
if CLIENT then
model:PushTriangle( a, b, c ) -- riser
model:PushTriangle( f, e, d )
model:PushTriangle( b, a, d ) -- face
model:PushTriangle( b, d, e )
model:PushTriangle( c, b, e ) -- tread
model:PushTriangle( c, e, f )
end
end
local isSolid = bit.band( tonumber( param.PrimSOPT ) or 0, 1 ) == 1
if isSolid then
local a = model:PushXYZ( run * count, width, 0 )
local b = model:PushXYZ( run * count, -width, 0 )
if physics then
model.convexes[#model.convexes + 1] = {
verts[count * 6 - 3],
verts[count * 6],
verts[1],
verts[4],
verts[a],
verts[b]
}
end
if CLIENT then
model:PushTriangle( count * 6 - 3, a, 1 ) -- side
model:PushTriangle( 4, b, count * 6 )
model:PushTriangle( b, a, count * 6 - 3 ) -- back
model:PushTriangle( b, count * 6 - 3, count * 6 )
model:PushTriangle( 1, a, b ) -- bottom
model:PushTriangle( 1, b, 4 )
end
else
if CLIENT then
model:PushTriangle( count * 6 - 3, count * 6, 4 )
model:PushTriangle( count * 6 - 3, 4, 1 )
end
end
util_Transform( model.verts, param.PrimMESHROT, param.PrimMESHPOS, threaded )
return model
end )

View File

@ -292,3 +292,17 @@ entclass.primitive_airfoil = function(partlist, ent, worldpos, worldang)
partlist[#partlist + 1] = part
end
entclass.primitive_staircase = function(partlist, ent, worldpos, worldang)
local vars = ent.primitive and ent.primitive.keys
if not istable(vars) or next(vars) == nil then return end
vars = table.Copy(vars)
vars.construct = "staircase"
local part = basic_info(partlist, ent, worldpos, worldang)
part.primitive = vars
partlist[#partlist + 1] = part
end

View File

@ -822,6 +822,9 @@ local function BuildPanel_ToolSettings(self)
local v = "primitive_airfoil"
choices[combo:AddChoice(v, onChoose, nil, class_list_filter[v] and "icon16/cross.png")] = v
local v = "primitive_staircase"
choices[combo:AddChoice(v, onChoose, nil, class_list_filter[v] and "icon16/cross.png")] = v
end
combo:AddSpacer()