logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Switching to mesh collision (Read 579 times)
gopostal
Betatester
Offline


Hack coder

Posts: 925
Joined: Jul 31st, 2008
Gender: Male
Switching to mesh collision
Feb 8th, 2019 at 3:08pm
Print Post  
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 <= 3.0))
 	  {
 	     Tree1(Other).remoterole = role_simulatedproxy;
         Tree1(Other).balwaysrelevant = true;
         Tree1(Other).setcollision(false,false,false);
         Tree1(Other).bhidden=true;
         Tree1(Other).mesh=none;
			Tree1(Other).drawtype = DT_None;
			ReplaceWithScaling(Other,"goHDProjectC.Tree1HD");
		}
      else return true;
      return false;
   } 


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
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1258
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Switching to mesh collision
Reply #1 - Feb 8th, 2019 at 4:11pm
Print Post  
gopostal wrote on Feb 8th, 2019 at 3:08pm:
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()); 


gopostal wrote on Feb 8th, 2019 at 3:08pm:
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.
  
Back to top
 
IP Logged
 
gopostal
Betatester
Offline


Hack coder

Posts: 925
Joined: Jul 31st, 2008
Gender: Male
Re: Switching to mesh collision
Reply #2 - Feb 9th, 2019 at 4:39am
Print Post  
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
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1258
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Switching to mesh collision
Reply #3 - Feb 9th, 2019 at 9:19am
Print Post  
gopostal wrote on Feb 9th, 2019 at 4:39am:
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.

gopostal wrote on Feb 9th, 2019 at 4:39am:
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.

gopostal wrote on Feb 9th, 2019 at 4:39am:
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?

gopostal wrote on Feb 9th, 2019 at 4:39am:
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?

gopostal wrote on Feb 9th, 2019 at 4:39am:
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).

gopostal wrote on Feb 9th, 2019 at 4:39am:
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.

gopostal wrote on Feb 9th, 2019 at 4:39am:
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.

gopostal wrote on Feb 9th, 2019 at 4:39am:
or does the collision scale along with the mesh?

Mesh-based collision is scaled by DrawScale automatically.
« Last Edit: Feb 9th, 2019 at 10:44am by Masterkent »  
Back to top
 
IP Logged
 
gopostal
Betatester
Offline


Hack coder

Posts: 925
Joined: Jul 31st, 2008
Gender: Male
Re: Switching to mesh collision
Reply #4 - Feb 9th, 2019 at 9:53am
Print Post  
Masterkent wrote on Feb 9th, 2019 at 9:19am:
If you do it right, it shouldn't be ignored.

I think you just summed up my ability Cheesy 

Masterkent wrote on Feb 9th, 2019 at 9:19am:
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
Back to top
 
IP Logged
 
gopostal
Betatester
Offline


Hack coder

Posts: 925
Joined: Jul 31st, 2008
Gender: Male
Re: Switching to mesh collision
Reply #5 - Feb 11th, 2019 at 3:31pm
Print Post  
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
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1258
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Switching to mesh collision
Reply #6 - Feb 11th, 2019 at 4:19pm
Print Post  
gopostal wrote on Feb 11th, 2019 at 3:31pm:
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 <NewRate>.

gopostal wrote on Feb 11th, 2019 at 3:31pm:
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.
  
Back to top
 
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3160
Joined: Aug 7th, 2011
Gender: Male
Re: Switching to mesh collision
Reply #7 - Feb 11th, 2019 at 8:25pm
Print Post  
gopostal wrote on Feb 11th, 2019 at 3:31pm:
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 crappity smacking 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.
  
Back to top
 
IP Logged
 
gopostal
Betatester
Offline


Hack coder

Posts: 925
Joined: Jul 31st, 2008
Gender: Male
Re: Switching to mesh collision
Reply #8 - Feb 12th, 2019 at 3:33am
Print Post  
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
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7894
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Switching to mesh collision
Reply #9 - Feb 13th, 2019 at 6:48am
Print Post  
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.
Back to top
WWWICQ  
IP Logged
 
.:..:
Board Moderator
Developer Team
*****
Offline



Posts: 1453
Location: Finland
Joined: Aug 16th, 2005
Gender: Male
Re: Switching to mesh collision
Reply #10 - Feb 14th, 2019 at 3:26pm
Print Post  
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.
  

Shivaxi wrote on Jul 25th, 2013 at 12:50pm:
...and now im stuck trying to fix everything you broke for the next 227 release xD Tongue

(ಠ_ಠ)
Back to top
IP Logged
 
gopostal
Betatester
Offline


Hack coder

Posts: 925
Joined: Jul 31st, 2008
Gender: Male
Re: Switching to mesh collision
Reply #11 - Feb 15th, 2019 at 3:48pm
Print Post  
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
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo