Prop to mesh tool

This addon is designed for building servers and constructors of vehicles which use a lot of props that reduce FPS. This addon will help solve this problem!

How it works:
Tool converts props into a mesh model and draws it for 1 time (than one prop for 1 time), this gives a huge performance boost.

Process:
Tool processes props on the client side (it is very costly process) and sends the compressed mesh data to the server where it is sent to the other players.
Props processing may temporarily reduce the performance of your game.

Advantages:

Disadvantages:

  • Default Tool uses the physical mesh (simplified than visual)
  • In rare cases, the IMesh causes glitches.
  • Getting a visual the mesh is unstable with some models.
  • Result has no physics and shadows.

Steam workshop link: http://steamcommunity.com/sharedfiles/filedetails/?id=846307650

This would be a great replacement to parenting. Would be a lot more efficient, however your render code is really inefficient, uses NWvars everywhere, and it doesn’t draw just one mesh.

and I don’t see why you need this code
[lua]
local matrix = Matrix();
matrix:Translate(self:GetPos())
matrix:Rotate(self:GetAngles())
matrix:Scale(Vector(1,1,1))

cam.PushModelMatrix(matrix)	

[/lua]

The draw hook should already do that internally.

well you’re wrong about that, obviously you have to tell the imesh where to draw and at what angle and scale

and this has several disadvantages, the most obvious being imeshes can only use one material and as such would only be a replacement for parenting if you export and uv map the mesh with a custom texture and then import it back

I’ve actually made a tool just like this that also has an export to/import from obj option

I wish the imesh library was better

It is mechanism of 3D graphics, can be used megatexture to solve it, but it will cause problems with the download speed and processing for clients.
UV coordinates is a big part of the data is bad for download from the server.
Export/import obj files will added with update in future.

not without a custom shader if the prop’s uv coordinates are tiled (eg, phx and sprops)

https://raw.githubusercontent.com/shadowscion/RandomLuaScripts/master/texture_atlas.lua

Wow! I’m a long time looking for something like that addon, but I had to do everything myself. Аddon not published in steam workshop?

Atlas with shader is really good idea, but i dont know gmod supports custom shaders with lua.
Well i can just split mesh by the tile size.
Oh… but altas not support material properties.

I never published it on workshop because I didn’t know how to network things when I made it, so it’s sort of half finished.

Had to test. Mesh material turned up as the default pink/black material no matter the settings I put in. Mesh from visual .mdl data was noisy, but I get why that is. Saving across sessions does not seem to work.

However I saw that the mesh does in fact cast dynamic shadows which was a nice surprise. I really would like to try and code a similar tool designed more for the posers among us rather than the builders.

Idea is great, execution less great IMO. I wish the tool would perform better (right now its not very functional for reliable usage).

Hm I thought the entity’s model matrix was already on the stack when the Draw hook is called. Anyway I think it might be more efficient to use cam.PushModelMatrix(self:GetBoneMatrix(0))

never realized that was a function

how can one even measure efficiency for things like this, though?

Compare benchmarks, but in this case, I would say thegrb is right just from inspection: the bone matrix is already preset so there’s so matrix operations that have to be done.

You could publish as beta or incomplete version.

I compared and GetBoneMatrix() in ~5 times faster than make a new matrix (0.0036 ms per operation)