Bladeren bron

Merge branch 'release/1.10.x'

rdb 4 jaren geleden
bovenliggende
commit
0c5fedfc9b

+ 9 - 0
panda/src/pgraph/renderState.cxx

@@ -746,6 +746,14 @@ get_num_unused_states() {
   for (size_t si = 0; si < size; ++si) {
   for (size_t si = 0; si < size; ++si) {
     const RenderState *state = _states.get_key(si);
     const RenderState *state = _states.get_key(si);
 
 
+    std::pair<StateCount::iterator, bool> ir =
+      state_count.insert(StateCount::value_type(state, 1));
+    if (!ir.second) {
+      // If the above insert operation fails, then it's already in the
+      // cache; increment its value.
+      (*(ir.first)).second++;
+    }
+
     size_t i;
     size_t i;
     size_t cache_size = state->_composition_cache.get_num_entries();
     size_t cache_size = state->_composition_cache.get_num_entries();
     for (i = 0; i < cache_size; ++i) {
     for (i = 0; i < cache_size; ++i) {
@@ -1843,6 +1851,7 @@ init_states() {
   // is declared globally, and lives forever.
   // is declared globally, and lives forever.
   RenderState *state = new RenderState;
   RenderState *state = new RenderState;
   state->local_object();
   state->local_object();
+  state->cache_ref_only();
   state->_saved_entry = _states.store(state, nullptr);
   state->_saved_entry = _states.store(state, nullptr);
   _empty_state = state;
   _empty_state = state;
 }
 }

+ 1 - 0
panda/src/pgraph/renderState.h

@@ -145,6 +145,7 @@ PUBLISHED:
   static void list_states(std::ostream &out);
   static void list_states(std::ostream &out);
   static bool validate_states();
   static bool validate_states();
   EXTENSION(static PyObject *get_states());
   EXTENSION(static PyObject *get_states());
+  EXTENSION(static PyObject *get_unused_states());
 
 
 PUBLISHED:
 PUBLISHED:
   // These methods are intended for use by low-level code, but they're also
   // These methods are intended for use by low-level code, but they're also

+ 25 - 0
panda/src/pgraph/renderState_ext.cxx

@@ -139,4 +139,29 @@ get_states() {
   return list;
   return list;
 }
 }
 
 
+/**
+ * Returns a list of all of the "unused" RenderState objects in the state
+ * cache.  See get_num_unused_states().
+ */
+PyObject *Extension<RenderState>::
+get_unused_states() {
+  extern struct Dtool_PyTypedObject Dtool_RenderState;
+  LightReMutexHolder holder(*RenderState::_states_lock);
+
+  PyObject *list = PyList_New(0);
+  size_t size = RenderState::_states.get_num_entries();
+  for (size_t si = 0; si < size; ++si) {
+    const RenderState *state = RenderState::_states.get_key(si);
+    if (state->get_cache_ref_count() == state->get_ref_count()) {
+      state->ref();
+      PyObject *a =
+        DTool_CreatePyInstanceTyped((void *)state, Dtool_RenderState,
+                                    true, true, state->get_type_index());
+      PyList_Append(list, a);
+      Py_DECREF(a);
+    }
+  }
+  return list;
+}
+
 #endif  // HAVE_PYTHON
 #endif  // HAVE_PYTHON

+ 1 - 0
panda/src/pgraph/renderState_ext.h

@@ -32,6 +32,7 @@ public:
   PyObject *get_composition_cache() const;
   PyObject *get_composition_cache() const;
   PyObject *get_invert_composition_cache() const;
   PyObject *get_invert_composition_cache() const;
   static PyObject *get_states();
   static PyObject *get_states();
+  static PyObject *get_unused_states();
 };
 };
 
 
 #endif  // HAVE_PYTHON
 #endif  // HAVE_PYTHON

+ 8 - 0
panda/src/pgraph/transformState.cxx

@@ -1017,6 +1017,14 @@ get_num_unused_states() {
   for (size_t si = 0; si < size; ++si) {
   for (size_t si = 0; si < size; ++si) {
     const TransformState *state = _states.get_key(si);
     const TransformState *state = _states.get_key(si);
 
 
+    std::pair<StateCount::iterator, bool> ir =
+      state_count.insert(StateCount::value_type(state, 1));
+    if (!ir.second) {
+      // If the above insert operation fails, then it's already in the
+      // cache; increment its value.
+      (*(ir.first)).second++;
+    }
+
     size_t i;
     size_t i;
     size_t cache_size = state->_composition_cache.get_num_entries();
     size_t cache_size = state->_composition_cache.get_num_entries();
     for (i = 0; i < cache_size; ++i) {
     for (i = 0; i < cache_size; ++i) {

+ 9 - 6
panda/src/x11display/x11GraphicsWindow.cxx

@@ -860,12 +860,15 @@ set_properties_now(WindowProperties &properties) {
   int value_mask = 0;
   int value_mask = 0;
 
 
   if (_properties.get_fullscreen()) {
   if (_properties.get_fullscreen()) {
-    changes.x = 0;
-    changes.y = 0;
-    value_mask |= CWX | CWY;
-    properties.clear_origin();
-
-  } else if (properties.has_origin()) {
+    if (_properties.get_x_origin() != 0 ||
+        _properties.get_y_origin() != 0) {
+      changes.x = 0;
+      changes.y = 0;
+      value_mask |= CWX | CWY;
+      properties.clear_origin();
+    }
+  }
+  else if (properties.has_origin()) {
     changes.x = properties.get_x_origin();
     changes.x = properties.get_x_origin();
     changes.y = properties.get_y_origin();
     changes.y = properties.get_y_origin();
     if (changes.x != -1) value_mask |= CWX;
     if (changes.x != -1) value_mask |= CWX;

+ 1 - 1
pandatool/src/assimp/assimpLoader.cxx

@@ -619,7 +619,7 @@ load_mesh(size_t index) {
   PT(GeomVertexArrayFormat) aformat = new GeomVertexArrayFormat;
   PT(GeomVertexArrayFormat) aformat = new GeomVertexArrayFormat;
   aformat->add_column(InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point);
   aformat->add_column(InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point);
   if (mesh.HasNormals()) {
   if (mesh.HasNormals()) {
-    aformat->add_column(InternalName::get_normal(), 3, Geom::NT_stdfloat, Geom::C_vector);
+    aformat->add_column(InternalName::get_normal(), 3, Geom::NT_stdfloat, Geom::C_normal);
   }
   }
   if (mesh.HasVertexColors(0)) {
   if (mesh.HasVertexColors(0)) {
     aformat->add_column(InternalName::get_color(), 4, Geom::NT_stdfloat, Geom::C_color);
     aformat->add_column(InternalName::get_color(), 4, Geom::NT_stdfloat, Geom::C_color);