For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Switching to mesh collision

Report bugs, read about fixes, new features and ask questions about the Unreal 227 patch here. Place comments and commit suggestions.
Post Reply
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Switching to mesh collision

Post by gopostal »

I've been working on my coop mod and I'm at a point now where I need to move my player base fully into i-forward so I can start using the new toolset.

I currently replace all the standard trees with high detail ones that have falling leaves, a few butterflies, and they can be burned to a charred stump. This works just fine as long as the drawscale remains 1 but in playing the coop maps almost none of the trees are placed that small.

I'd like to allow for 1X to 3X (maybe even 5 at some point) but the issue I run into is collision height/radius. I'm learning as I go with the tools available now in 227 so this may seem a basic question. Is it possible to change the replaced tree and have my new one use mesh collision for itself? This would fix the problem completely I think?

My replace code (nothing weird)

Code: Select all

function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
      if(Other.Class==Class'Tree1')
   {
         if((Tree1(Other).DrawScale >= 1.0) && (Tree1(Other).DrawScale 
and obviously my new tree is !bStatic.
I don't want to give the end away
but we're all going to die one day
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Switching to mesh collision

Post by Masterkent »

I'd like to allow for 1X to 3X (maybe even 5 at some point) but the issue I run into is collision height/radius.
CollisionHeight and CollisionRadius can be changed dynamically by means of the native function Actor.SetCollisionSize:

Code: Select all

A.SetCollisionSize(A.default.CollisionRadius * (A.DrawScale / A.default.DrawScale), A.default.CollisionHeight * (A.DrawScale / A.default.DrawScale));
In case of using 227j, this code can be reduced to

Code: Select all

A.SetCollisionSize(A.ScaledDefaultCollisionRadius(), A.ScaledDefaultCollisionHeight());
Is it possible to change the replaced tree and have my new one use mesh collision for itself?
That is possible, you can set bUseMeshCollision to true. But you should keep in mind that bUseMeshCollision is not replicated to clients (therefore, when you set bUseMeshCollision to true or false server-side, the client-side value of bUseMeshCollision won't be automatically changed to match the server-side value). You'll have to either use bUseMeshCollision=true in defaultproperties of your decoration subclass or dynamically set this flag client-side somehow.
Last edited by Masterkent on Fri Feb 08, 2019 4:14 pm, edited 1 time in total.
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Switching to mesh collision

Post by gopostal »

The problem of just scaling drawsize and collision is that mappers use all kinds of values when they start scaling things. An example of what I'm talking about is Nyleve:

There are 11 Tree5's in the map and they all have drawscale 3.0. However the collision height on them varies from 200 to 300.

It's very common for mappers to just start tossing numbers in that look good in editor so when I replace them I need to match up those figures to preserve site-specific things that may be happening.

I tried to work around this by applying this to the ReplaceMe code

Code: Select all

            A.SoundPitch =  Other.CollisionHeight;
            A.SoundRadius = Other.CollisionRadius;
then setting the collision up within the tree itself once it was spawned:

Code: Select all

function PostBeginPlay()
{
      local float H, R;

      Super.PostBeginPlay();
      SoundPitch = H;
      SoundRadius = R;
      SetCollisionSize(H,R);
This doesn't work (no surprise, I'm spitballing a bit) but it seemed to me like mesh collision would fix all of this. I tried to set my trees to use mesh collision but it's being ignored. Is that due to the drawscale change or does the collision scale along with the mesh?
I don't want to give the end away
but we're all going to die one day
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Switching to mesh collision

Post by Masterkent »

The problem of just scaling drawsize and collision is that mappers use all kinds of values when they start scaling things.
That doesn't actually imply that the mappers well understand what they are doing.
An example of what I'm talking about is Nyleve:

There are 11 Tree5's in the map and they all have drawscale 3.0. However the collision height on them varies from 200 to 300.
If you try to jump on tops of those trees, you can quickly notice that 200 is insufficient half-height (you land inside the tree) and 300 is too big half-height (you land above the tree). The optimal half-height is close to 240 which is equal to the default.CollisionHeight (which is 80) multiplied by DrawScale / default.DrawScale (which is 3).

200 and 300 don't look like reasonable values.
It's very common for mappers to just start tossing numbers in that look good in editor so when I replace them I need to match up those figures to preserve site-specific things that may be happening.
What exactly do you want to achieve by matching up some randomly chosen values?
I tried  to work around this by applying this to the ReplaceMe code

Code: Select all

            A.SoundPitch =  Other.CollisionHeight;
            A.SoundRadius = Other.CollisionRadius;
How are sound properties related to collision metrics?
then setting the collision up within the tree itself once it was spawned:

Code: Select all

function PostBeginPlay()
{
      local float H, R;

      Super.PostBeginPlay();
      SoundPitch = H;
      SoundRadius = R;
      SetCollisionSize(H,R);
Firstly, PostBeginPlay is called right in the Spawn function. When Spawn returned the reference to the newly spawned actor in the caller function, PostBeginPlay already have been executed. Hence, this part

Code: Select all

            A.SoundPitch =  Other.CollisionHeight;
            A.SoundRadius = Other.CollisionRadius;
is executed _after_ A's PostBeginPlay.

Secondly, local variables H and R are not changed anywhere, so you basically pass zeroes to SetCollisionSize. Note also that SetCollisionSize accepts half-radius as the first argument and half-height as the second argument (not vice versa).
but it seemed to me like mesh collision would fix all of this.
SetCollisionSize should be sufficient unless you want to replace fast cylindrical collision model with more realistic collision model based on shape of the mesh.
I tried to set my trees to use mesh collision but it's being ignored.
If you do it right, it shouldn't be ignored.
or does the collision scale along with the mesh?
Mesh-based collision is scaled by DrawScale automatically.
Last edited by Masterkent on Sat Feb 09, 2019 10:44 am, edited 1 time in total.
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Switching to mesh collision

Post by gopostal »

If you do it right, it shouldn't be ignored.
I think you just summed up my ability :D
Mesh-based collision is scaled by DrawScale automatically.
That's exactly what I needed to know.

I appreciate you taking the time to tear my question into manageable chunks and deal with them each. It's way easier for me to learn that way. I think I understand it enough now to deal with the tree replacing properly.
I don't want to give the end away
but we're all going to die one day
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Switching to mesh collision

Post by gopostal »

Follow up question...

I've been using the mesh collision and it works really well. For the first time I'm forced to shoot through the tree limbs carefully. Hell yeah!

With mesh collision is there a cost to the server performance? I mean can I start switching over to it with my new models to be the norm or does this create larger overhead? Oh, and what will my player base be restricted to once I put this on the server (so I can advertise the change)?

BTW, a pet project of mine for many years has been a constructor gun. If I created 'lego' bricks with mesh collision does this become more of a possibility now? Cylinder collision always made it impossible to work. I've always wanted to have a builder server where people could "Minecraft" their own places. Construction servers existed for a while in 2k4 and it was glorious.
I don't want to give the end away
but we're all going to die one day
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Switching to mesh collision

Post by Masterkent »

With mesh collision is there a cost to the server performance?
Theoretically, cylindrical collision should work faster. I guess, the only feasible way to find out how much mesh-based collision would cost when applied to a particular set of actors is experimenting with it. The difference can be observed by comparing real server tick rate before and after changing cylindrical collision to mesh-based (you should initially request a high value - such as 120 ticks per second). Prototype's admin scoreboard displays the current real tick rate and requested tick rate at the left bottom corner; the requested value can be changed by admin command TickRate .
and what will my player base be restricted to once I put this on the server (so I can advertise the change)?
227i or the latest 227j.
Last edited by Masterkent on Mon Feb 11, 2019 4:27 pm, edited 1 time in total.
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Switching to mesh collision

Post by []KAOS[]Casey »

I've always wanted to have a builder server where people could "Minecraft" their own places. Construction servers existed for a while in 2k4 and it was glorious.
there is a mod called "builder" I think which does that using normal meshes and uses bsp collision and works on all clients, but non 227 clients crash a fucking lot there (shocker). also meshes are extremely laggy once you put enough of them down. can't recall if servers are stable with it either, to be honest.
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Switching to mesh collision

Post by gopostal »

My thinking on this was to let players build up a structure the way they like. On a set schedule the server would be stopped and the meshes could be converted to BSP manually. This updated map would then be the current map and the process would continue. This would only be for the structure part of the building process but it could do away with the largest chunk of the stacked mesh problems. Once a structure was where the player was happy then it could be locked into the map and they could decorate as they saw fit. Texturing, decoration placements, etc. would all be easy then.

I did a version of this years ago for Herm's group. I gave them all the same house in a demo map and they decorated it like they wanted. Once everyone was done I assembled the houses into a village and added stuff to do in the town.

I wouldn't mind another project like that but I'd like to have the proper framework supporting it before I began something so comprehensive. I think it might be nice thought to have an Unreal players town that was inclusive and neutral and was a place players could meet up and chat/ play games/ whatever.
I don't want to give the end away
but we're all going to die one day
User avatar
Smirftsch
Administrator
Posts: 8999
Joined: Wed Apr 29, 1998 10:00 pm
Location: NaPali
Contact:

Re: Switching to mesh collision

Post by Smirftsch »

Mesh Collision definitely is way more expensive. To tell how hard the impact on nowadays machines is, should be tested. I think if not abusing it to much, it should be ok.
Sometimes you have to lose a fight to win the war.
User avatar
.:..:
OldUnreal Member
Posts: 1634
Joined: Tue Aug 16, 2005 4:35 am

Re: Switching to mesh collision

Post by .:..: »

Depending on the mesh, if it has a lot of polies clumped up together, you may want to create a simple collision model for the mesh. But if it is a large mesh with lesser polies near each other (it does have an internal octree filter node system for collision testing), it will perform just as-well as BSP collision.

Using a bunch of collision cylinders to create a seemingly 3D collision shape is actually slower because the collision octree filtering for actors will bottleneck that.
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Switching to mesh collision

Post by gopostal »

Thank you for your explanations. In my coop server I replace almost all the standard decoration classes with my own reactive stuff to add immersion. I'm going to start mixing in mesh-collision replacements with my swaps and see where it starts to impact performance.

I can tell you that the tree replacements are just fantastic so I'm looking forward to peppering in more.
I don't want to give the end away
but we're all going to die one day
Post Reply

Return to “Unreal 227”