Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene object refactoring #1209

Merged
merged 26 commits into from
Dec 1, 2023
Merged

Scene object refactoring #1209

merged 26 commits into from
Dec 1, 2023

Conversation

Licini
Copy link
Contributor

@Licini Licini commented Nov 10, 2023

Hey guys, so this PR is about the refactoring all Artist to SceneObject. It may look like a huge PR, but besides the addition of scene class, all the rests are renaming and adjusting importing path. Basically compas.artists is now compas.scene.

Before I make the file changing list even longer, I want to make sure if we all agree on this new folder structure and naming convention:

  • All previous artists classes will be renamed to corresponding scene object classes:
    • base class Artist to SceneObject
    • Derived classes like MeshArtist to MeshObject, NetworkArtist to NetworkObject etc.
  • Both Scene and SceneObject is now under compas.scene, let me know if you guys think there should be a separate folder of compas.sceneobjects.

Now I have done renaming for compas core folder. If you guys are OK with this pattern I will finish the rest for compas_rhino, compas_ghpython and compas_blender.

Screen Shot 2023-11-10 at 12 59 17

@Licini
Copy link
Contributor Author

Licini commented Nov 30, 2023

Blender
image

GH
image

Rhino
image

@Licini
Copy link
Contributor Author

Licini commented Nov 30, 2023

@tomvanmele @gonzalocasas @chenkasirer Ok this one is ready. As discussed I'd like to make this PR only about renaming and make the basic scene setup work. Plz see the script at docs/userguide/tutorials/scene/scene.py which runs the same in three places above. Once this one is merged. I will continue to make following PRs to make the Scene mechanism complete:

  • Move functions like redraw and clear from SceneObject (formerly Artist) to Scene.
  • Proper serialization of everything inside a Scene.
  • Have all geometries and datastructures work properly everywhere (right now there are few left).
  • Unifying the guid tracking mechanism for all SceneObjects.
  • Handling of transformation stacks.
  • (Lastly, hash tree of scene)

@Licini Licini marked this pull request as ready for review November 30, 2023 17:10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example here

docs/reference/compas.rst Outdated Show resolved Hide resolved
docs/reference/compas.scene.rst Outdated Show resolved Hide resolved
docs/reference/compas_blender.rst Outdated Show resolved Hide resolved
docs/reference/compas_ghpython.rst Outdated Show resolved Hide resolved
docs/reference/compas_rhino.rst Outdated Show resolved Hide resolved
docs/userguide/configuration/grasshopper.rst Show resolved Hide resolved
@@ -17,11 +17,11 @@
# Visualisation
# ==============================================================================

Artist.clear()
SceneObject.clear()
Copy link
Member

Choose a reason for hiding this comment

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

this is wrong and there are many like this.
however, all files in this folder were copied from occ to be able to do some compatibility testing.
they are not meant to be part of the docs.
please remove...

class GeometryArtist(Artist):
"""Base class for artists for geometry objects.
class GeometryObject(SceneObject):
"""Base class for sceneobjects for geometry objects.
Copy link
Member

Choose a reason for hiding this comment

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

perhaps do find replace scene object

@@ -145,7 +145,7 @@ def draw_nodes(
for node in nodes or self.network.nodes(): # type: ignore
name = f"{self.network.name}.node.{node}" # type: ignore
color = self.node_color[node] # type: ignore
point = self.node_xyz[node] # type: ignore
point = self.network.nodes_attributes("xyz")[node] # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

why are you changing this everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These was because they were creating double transformation. the node_xyz already preforms the transformation, then later self.update_object is doing that again.

Copy link
Member

Choose a reason for hiding this comment

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

ok but then perhaps remove the node_xyz dict

@@ -153,7 +153,7 @@ def draw_vertices(
for vertex in vertices or self.volmesh.vertices(): # type: ignore
name = f"{self.volmesh.name}.vertex.{vertex}" # type: ignore
color = self.vertex_color[vertex] # type: ignore
point = self.vertex_xyz[vertex]
point = self.volmesh.vertices_attributes("xyz")[vertex]
Copy link
Member

Choose a reason for hiding this comment

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

Why are you changing this everywhere?

@Licini
Copy link
Contributor Author

Licini commented Dec 1, 2023

@tomvanmele all done, let me know how it looks now : )

@@ -193,7 +193,7 @@ def get_geometry(self, with_features=False):
"""
Returns a transformed copy of the part's geometry.

The returned type can be drawn with an Artist.
The returned type can be drawn with an scene object.
Copy link
Member

Choose a reason for hiding this comment

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

an => a

class VolMeshArtist(Artist):
"""Artist for drawing volmesh data structures.
class VolMeshObject(SceneObject):
"""Sceneobject for drawing volmesh data structures.
Copy link
Member

Choose a reason for hiding this comment

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

Scene object?
SceneObject?

class BoxArtist(BlenderArtist, GeometryArtist):
"""Artist for drawing box shapes in Blender.
class BoxObject(BlenderSceneObject, GeometryObject):
"""Sceneobject for drawing box shapes in Blender.
Copy link
Member

Choose a reason for hiding this comment

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

same question everywhere i guess

@Licini
Copy link
Contributor Author

Licini commented Dec 1, 2023

Oops, all fixed 🤣 @tomvanmele

@Licini Licini merged commit 51416db into main Dec 1, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants