Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Various brush entity improvements and fixes#24

Merged
codecat merged 1 commit into
codecat:masterfrom
EIRTeam:brush_entities_fixes
Aug 31, 2022
Merged

Various brush entity improvements and fixes#24
codecat merged 1 commit into
codecat:masterfrom
EIRTeam:brush_entities_fixes

Conversation

@EIREXE

@EIREXE EIREXE commented Aug 28, 2022

Copy link
Copy Markdown
Contributor

This includes:

  • Generate one mesh instance per entity, instead of one mesh instance per texture, this seems like a much more sensible way than using one meshinstance per texture
  • Fix the rotation of brush entities, previously the transform was applied on top, however this is wrong as the brush entity's geometry is already in godot space (and brush entities have no rotation anyways).
  • Always generate visuals for brush entities, this is because a brush entity doesn't have to make use of collision at all
  • Generate brush entity collisions as siblings of the mesh instance if the brush entity is of a physics type, this is so the parent is the one that handles all the physics of the brush entity

@EIREXE EIREXE changed the title Various brush entity improvements Various brush entity improvements and fixes Aug 28, 2022
@codecat

codecat commented Aug 28, 2022

Copy link
Copy Markdown
Owner

Thanks for the PR! I'll take a closer look at the code hopefully tomorrow.

a brush entity doesn't have to make use of collision at all

Right, but the opposite is also correct; not all brushes need visual but do need collision, for example invisible walls. Would that still be possible with this change?

@EIREXE

EIREXE commented Aug 28, 2022

Copy link
Copy Markdown
Contributor Author

Thanks for the PR! I'll take a closer look at the code hopefully tomorrow.

a brush entity doesn't have to make use of collision at all

Right, but the opposite is also correct; not all brushes need visual but do need collision, for example invisible walls. Would that still be possible with this change?

Invisible walls IMO should be done with a special clip texture like quake/source does that is configured in the TBLoader node, I have such thing implemented already in my own branch but it's not in this PR, my plan was to add it together with nodraw textures for skipping faces as a separate PR.

@codecat

codecat commented Aug 29, 2022

Copy link
Copy Markdown
Owner

Most of the code looks good! 🎉

One thing I don't understand though is why are you passing ColliderType::None to build_entity_mesh and then calling add_collider_from_mesh later? That should already happen correctly in build_entity_mesh, shouldn't it?

I also have some minor style nitpicks if you wouldn't mind changing them 😊
image

@codecat

codecat commented Aug 29, 2022

Copy link
Copy Markdown
Owner

Invisible walls IMO should be done with a special clip texture like quake/source does that is configured in the TBLoader node

I agree, but I think it should work both ways too. Perhaps this is not a problem though, particularly because I also want to allow customizing whether visual/collision is enabled through entity properties. (But that's for a separate issue/commit)

@EIREXE EIREXE force-pushed the brush_entities_fixes branch from 97e5ffa to 7dfcf3a Compare August 29, 2022 21:56
@EIREXE

EIREXE commented Aug 29, 2022

Copy link
Copy Markdown
Contributor Author

One thing I don't understand though is why are you passing ColliderType::None to build_entity_mesh and then calling add_collider_from_mesh later? That should already happen correctly in build_entity_mesh, shouldn't it?

Because the idea is that in the case of brush entities collision shapes should always be children of the entity instead of children of the mesh as is the case in static mode.

I also have some minor style nitpicks if you wouldn't mind changing them blush

Should be OK now

@codecat

codecat commented Aug 31, 2022

Copy link
Copy Markdown
Owner

Because the idea is that in the case of brush entities collision shapes should always be children of the entity instead of children of the mesh as is the case in static mode.

This is why, when passing ColliderType::Mesh to build_entity_mesh, it adds the collider using add_collider_from_mesh to the specified parent. I think it would do the same if you pass a mesh collider type using need_collider = ColliderType::Mesh;, similarly to how it is done for RigidDynamicBody3D.

@EIREXE EIREXE force-pushed the brush_entities_fixes branch from 7dfcf3a to 9a99aae Compare August 31, 2022 17:03
@EIREXE

EIREXE commented Aug 31, 2022

Copy link
Copy Markdown
Contributor Author

Because the idea is that in the case of brush entities collision shapes should always be children of the entity instead of children of the mesh as is the case in static mode.

This is why, when passing ColliderType::Mesh to build_entity_mesh, it adds the collider using add_collider_from_mesh to the specified parent. I think it would do the same if you pass a mesh collider type using need_collider = ColliderType::Mesh;, similarly to how it is done for RigidDynamicBody3D.

Hmm yeah you are right, I've gone ahead and done that

Comment thread src/builder.cpp Outdated
add_collider_from_mesh(node, mesh, need_collider_shape);
}
}
MeshInstance3D* mesh_instance = build_entity_mesh(idx, ent, node, ColliderType::Mesh, need_collider_shape);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to use need_collider here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I'm dumb

This includes:
- Generate one mesh instance per entity, instead of one mesh instance per texture, this seems like a much more sensible way than using one meshinstance per texture
- Fix the rotation of brush entities, previously the transform was applied on top, however this is wrong as the brush entity's geometry is already in godot space (and brush entities have no rotation anyways).
- Always generate visuals for brush entities, this is because a brush entity doesn't have to make use of collision at all
- Generate brush entity collisions as siblings of the mesh instance if the brush entity is of a physics type, this is so the parent is the one that handles all the physics of the brush entity
@EIREXE EIREXE force-pushed the brush_entities_fixes branch from 9a99aae to 3b6d7ca Compare August 31, 2022 17:08
Comment thread src/builder.cpp
Comment on lines +421 to +422
// Create instance name based on entity idx
String instance_name = String("entity_{0}_geometry").format(Array::make(idx));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this loses the entity name given in Trenchbroom. Do we really need that?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this might only lose the texture name, so it probably doesn't matter that much.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the point of that is that since we are now grouping textures into one mesh its a better idea to just use the entity id

@codecat codecat merged commit a5cdd77 into codecat:master Aug 31, 2022
@codecat

codecat commented Aug 31, 2022

Copy link
Copy Markdown
Owner

Thank you! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants