[Examples!] BasePart Deconstructor (BPD) - Simplify BasePart Geometry


INTRODUCTION


BasePart Deconstructor (BPD) deconstructs BaseParts (currently only Wedges and CornerWedges) into simpler constituent parts, such as WedgePart to Part and CornerWedge to WedgePart, and additionally includes truncation of CornerWedges.

Whatever parts you select and all their descendants will be deconstructed by the method you choose, with the original parts optionally deleted.

Plugin link and Model link

Current plugin GUI (Detailed description of the deconstruction types below):


Current deconstruction methods:

Wedge:

image


Face: Makes the hypotenuse face (longest face) into a BasePart
image


Full: Same as Face, but the thickness is automatically set to the max extension of the Wedge.
image


Shell: Same as face, but adds parts on the sides of the wedge that reach to the max extension.
image


Left & Right shell: Same as shell, but only creates the left/right sides
image image



CornerWedge:

image

Faces: Makes the main outwards faces of the CornerWedge into Wedges.
image image


Truncated: Removes the corner of the CornerWedge, effectively making it a triangle.
image


How BPD can be useful:

  • Converting old wedge and corner-wedge models (For interior space and functionality):

When you only need the outermost faces of a wedge or cornerwedge, the rest becomes unnecessary and in the case of interiors, can save valuable space while promoting a more realistic look. The plugin does this perfectly, and sets the new part faces in the exact position where they can replace the old part’s look entirely. Additionally, the plugin auto-parents the old part’s objects to the new part (or only one of the parts in the case of corner wedge), and auto-welds unanchored parts, giving it a very streamlined conversion, and making it perfect for moving objects/vehicles.

I had made a model a while ago using wedges & corner wedges that I liked the (exterior) look of and didn’t want to bother manually converting into parts:

Interior of my vehicle before conversion

After

(The exterior looks the exact same, when using the right & left shell methods where applicable)

Rectangular parts being easier/more versatile was my original use case for the plugin and what inspired it. I mainly wanted make the wedges into parts because a system I’m working on required rectangular parts and not wedges or CornerWedges, but it also happens to make the models look better.

  • Stylistic design & “Plating” (Through addition of part faces)

With the plugin, you can choose to “keep” the original part(s), which can give you complete freedom over what to do with the faces of the part, effectively giving you “layers” to work with. Here are some examples where it could be used for style:

While this specific task can be done with no scripting knowledge with regular parts, this plugin makes it way simpler and easier, automatically setting the part to the right dimensions and position within the part.

  • Ease of use and much faster building

With this plugin, you can build using the much easier-to-use wedges and corner wedges, easily creating the angles you want, while also throwing away the often unnecessary and ugly-looking backsides of wedges! Additionally, the custom thickness parameter lets you set the thickness of the resulting part, meaning you can make tanks, ships, roofs, sails, whatever you want, to be whatever part thickness you want.

Here’s a boat hull I threw together really quick (~5 mins) with a bunch of wedges and corner wedges: image

The picture on the right is entirely made with the plugin by converting the parts of the left. Using the left and right shell methods gave those useful parts at the end of the boat, which will make it much easier to build the full back of the boat:

image

Let’s continue with the boat to show where this can be useful in other cases while building, by building a sail!.

image image

Due to the incredible ease-of-use of wedge parts, I was able to make this decent-looking sail in about 2 minutes!

image

Now we have a decent-looking boat in <10 minutes, with the power of wedges! (With a hollow space underneath for players!) Keep in mind I’m mostly a programmer and have very limited building experience, so it’s not hard to imagine a boat that looks even better using this workflow.

  • Truncated Corner Wedges

Creating the shape mentioned in this thread (which I call a truncated corner wedge) was prohibitively time-consuming to do with roblox BaseParts (outside of unions, which have a ton of problems), but with this plugin, it becomes as easy as just placing down a corner wedge and clicking a button!

image image

Performance

Converting wedges using the most costly method (Shell without anchoring) takes about 0.0002 seconds per wedge, and has O(n) time complexity. Both corner wedge options are much less expensive from benchmarks. For the most costly method, lag is unnoticeable on your average device until around 5000 parts (~0.5 seconds worst case!), and is reasonable under 20000 parts (~4 seconds!), which should be more than enough for any implementation. (Seriously, I would be surprised if any plugin didn’t lag at 20000 parts).

Even at any amount of parts above that, the plugin will eventually convert all your parts, with the most likely thing to crash being studio by auto-selecting the gigantic amount of parts created from the operation, so I’d recommend staying below converting ~100000 parts at a time, as from experience working with selecting huge amounts of instances, studio starts to be unusable around that order of magnitude.

image

This took 0.14 seconds to execute (4096 truncated corner wedges) (0.000034 seconds per wedge)



Currently I have no plans to expand this plugin to other cases, such as full decomposition (just hollowing the part out) other decomposition styles, and regular Parts and the Ball and Cylinder shapes that come with them -- but let me know if you'd like these features: I might implement them if there's enough demand!
19 Likes

Interesting plugin, however, I’m confused on how this would be useful. Do you have any examples of this being used?

1 Like

Yes! I actually created the original scripts for this plugin for my own needs, after not being able to find anything like it online, only then did I decide to make a plugin for it.

[Use cases incorporated into main post above ^ ]

I will add this to the main post ASAP as I’m sure many people have the same question since nobody has taken the plugin yet lol.

2 Likes

Love it, it is gonna be useful!

Quick question, have you done anything to minimize performance impact? Since you are turning 1 part into multiple, it could be bad for performance with a lot of these deconstructed parts.

Short answer: No; it doesn’t need to be minimized.

Long answer: I created this plugin in mind with converting huge amounts of wedges and cornerwedges for personal use with models. It runs extremely quickly on my pc (which is a very average rig for today), with >1500 wedges converted and zero noticeable lag, so nobody should really have performance issues until parts approach the tens of thousands and up (at which point any script or plugin would have performance issues).

Not many calculations need to be done per part, and the most performance-intensive part of the program would almost definitely be the instancing of parts themselves, which there is absolutely no way to get around short of pre-instancing, which would have a large up-front performance impact with the performance, and have a limit to its own usefulness (see below). And of course, nothing can be done about the lag caused by the new parts existing, since they’re the whole point of the plugin.

That being said, I have done absolutely nothing to minimize performance impact, since it’s not necessary in any way. Personally, I used to be obsessed with writing the most performant code possible off the bat, but after seeing so many in the developer community advocating against micro-optimizations and just getting code that works first then optimizing if necessary, I questioned my own methods and realized pre-optimizing is a waste of time (to a degree, you obviously shouldn’t go around using methods that take many times more processing power than needed). It’s important to analyze the performance impact of any software, of course, but action doesn’t need to be taken to optimize it unless it would actually improve user experience (which I will go into below).


Performance Analysis

Simple math computations are incredibly cheap these days. Running a quick benchmark shows that the calculations for one “Face” part take only ~3 e-7 seconds, or 0.0000009 seconds for the full shell (3 “face” parts per wedge) example below. This could be made up to 3x faster by sharing values between the new face functions, but is completely unnecessary as the full execution takes ~0.3 seconds for all of the parts (~1.9e-4 per part), which is less than 1/200th of the actual process spent doing math, meaning optimizing the math by a factor of 3 as stated earlier would shorten the execution time by less than 1/600th of the whole time, humanly unnocitable in relation to the rest of the process. Pre-instancing (creating the part before you use the plugin) could actually make the performance significantly better, but comes at a cost, which would be having to store a large amount of instances in your device’s memory, and potentially lagging everything else in studio, and definitely lagging your device on plugin startup, and even then, would probably only impact execution times by a factor of about 1/2, since other options such as CFraming, welding, re-parenting, and copying properties still need to be done. These other operations pretty much can’t be cut down on without just turning their features off, which would either needlessly add to the complexity of the plugin (by adding toggles) or take very useful/needed features away.


1536 wedges with full shells (4608 parts) created with no noticeable lag!


To answer your question, did I optimize it? No.
Would optimizing it actually make it better? No.

Thanks for asking this question, it actually made me actually consider how to approach the question of optimization from an analysis perspective, and I think I will apply this to future scripts/programs I’ll write.

1 Like

Wow, thank you for providing such a clear, concise, and proven answer to my seemingly simple question. I must applaud your effort in proving why you did what you did, and answering my question. And it is no problem, I just happened to be in the right place to change your mind. :grinning_face_with_smiling_eyes:

1 Like