This encapsulates Node socket members behind a set of specific methods; as such it is no longer possible to directly access Node class members from exporters and parts of Cycles. The methods are defined via the NODE_SOCKET_API macros in `graph/ node.h`, and are for getting or setting a specific socket's value, as well as querying or modifying the state of its update flag. The setters will check whether the value has changed and tag the socket as modified appropriately. This will let us know how a Node has changed and what to update, which is the first concrete step toward a more granular scene update system. Since the setters will tag the Node sockets as modified when passed different data, this patch also removes the various modified methods on Nodes in favor of Node::is_modified which checks the sockets' update flags status. Reviewed By: brecht Maniphest Tasks: T79174 Differential Revision: https://developer.blender.org/D8544
95 lines
2.8 KiB
C++
95 lines
2.8 KiB
C++
/*
|
|
* Copyright 2011-2013 Blender Foundation
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "render/mesh.h"
|
|
#include "render/object.h"
|
|
#include "render/particles.h"
|
|
|
|
#include "blender/blender_sync.h"
|
|
#include "blender/blender_util.h"
|
|
|
|
#include "util/util_foreach.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
/* Utilities */
|
|
|
|
bool BlenderSync::sync_dupli_particle(BL::Object &b_ob,
|
|
BL::DepsgraphObjectInstance &b_instance,
|
|
Object *object)
|
|
{
|
|
/* test if this dupli was generated from a particle sytem */
|
|
BL::ParticleSystem b_psys = b_instance.particle_system();
|
|
if (!b_psys)
|
|
return false;
|
|
|
|
object->set_hide_on_missing_motion(true);
|
|
|
|
/* test if we need particle data */
|
|
if (!object->get_geometry()->need_attribute(scene, ATTR_STD_PARTICLE))
|
|
return false;
|
|
|
|
/* don't handle child particles yet */
|
|
BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id = b_instance.persistent_id();
|
|
|
|
if (persistent_id[0] >= b_psys.particles.length())
|
|
return false;
|
|
|
|
/* find particle system */
|
|
ParticleSystemKey key(b_ob, persistent_id);
|
|
ParticleSystem *psys;
|
|
|
|
bool first_use = !particle_system_map.is_used(key);
|
|
bool need_update = particle_system_map.add_or_update(&psys, b_ob, b_instance.object(), key);
|
|
|
|
/* no update needed? */
|
|
if (!need_update && !object->get_geometry()->is_modified() &&
|
|
!scene->object_manager->need_update)
|
|
return true;
|
|
|
|
/* first time used in this sync loop? clear and tag update */
|
|
if (first_use) {
|
|
psys->particles.clear();
|
|
psys->tag_update(scene);
|
|
}
|
|
|
|
/* add particle */
|
|
BL::Particle b_pa = b_psys.particles[persistent_id[0]];
|
|
Particle pa;
|
|
|
|
pa.index = persistent_id[0];
|
|
pa.age = b_scene.frame_current() - b_pa.birth_time();
|
|
pa.lifetime = b_pa.lifetime();
|
|
pa.location = get_float3(b_pa.location());
|
|
pa.rotation = get_float4(b_pa.rotation());
|
|
pa.size = b_pa.size();
|
|
pa.velocity = get_float3(b_pa.velocity());
|
|
pa.angular_velocity = get_float3(b_pa.angular_velocity());
|
|
|
|
psys->particles.push_back_slow(pa);
|
|
|
|
object->set_particle_system(psys);
|
|
object->set_particle_index(psys->particles.size() - 1);
|
|
|
|
if (object->particle_index_is_modified())
|
|
scene->object_manager->tag_update(scene);
|
|
|
|
/* return that this object has particle data */
|
|
return true;
|
|
}
|
|
|
|
CCL_NAMESPACE_END
|