Welcome to mirror list, hosted at ThFree Co, Russian Federation.

stats.py « scene « amaranth - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 71d107415459c54987657af1450227542bbbf3a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# SPDX-License-Identifier: GPL-2.0-or-later
"""
Scene, Cameras, and Meshlights Count

Increase the stats by displaying the number of scenes, cameras, and light
emitting meshes.
On the Info header.
"""

import bpy
from amaranth import utils


def stats_scene(self, context):
    get_addon = "amaranth" in context.preferences.addons.keys()
    if not get_addon:
        return

    if context.preferences.addons["amaranth"].preferences.use_scene_stats:
        scenes_count = str(len(bpy.data.scenes))
        cameras_count = str(len(bpy.data.cameras))
        cameras_selected = 0
        meshlights = 0
        meshlights_visible = 0

        for ob in context.scene.objects:
            if utils.cycles_is_emission(context, ob):
                meshlights += 1
                if ob in context.visible_objects:
                    meshlights_visible += 1

            if ob in context.selected_objects:
                if ob.type == 'CAMERA':
                    cameras_selected += 1

        meshlights_string = '| Meshlights:{}/{}'.format(
            meshlights_visible, meshlights)

        row = self.layout.row(align=True)
        row.label(text="Scenes:{} | Cameras:{}/{} {}".format(
                  scenes_count, cameras_selected, cameras_count,
                  meshlights_string if utils.cycles_active(context) else ''))


def register():
    bpy.types.STATUSBAR_HT_header.append(stats_scene)


def unregister():
    bpy.types.STATUSBAR_HT_header.remove(stats_scene)