In such context, it may be suitable to define a function $w$, called weighting function, that to any point of space $\mathbf{x}$ associates a continuous fictional mass value.
This fictional mass value takes into consideration the mass $m_i$ of particles around its position and weights them with their relative position $\mathbf{x}_i(t)-\mathbf{x}$.
The condition we want to assess is that no mass is over or under weighted in the process, so that for a volume $\mathcal{V}$ in space
$$w(\mathbf{x}_i(t)-\mathbf{x})\;\;\;\;\big|\;\;\;\;\int_{\mathcal{V}}\,\sum_i\,m_i\,w(\mathbf{x}_i(t)-\mathbf{x})\;dV_{\mathbf{x}}=\sum_i\,m_i$$
or equivalently, bringing integral in and simplifying mass
$$\qquad w\equiv w(\mathbf{x}_i(t)-\mathbf{x})\;\;\;\;\big|\;\;\;\;\int_{\mathcal{V}}w(\mathbf{x}_i(t)-\mathbf{x})\;dV_{\mathbf{x}}=1\qquad\qquad\qquad\textbf{Weighting function}$$
It may be assessed that the following relation holds for $w$
$$\nabla w=\frac{\partial w(\mathbf{x}_i(t)-\mathbf{x})}{\partial\mathbf{x}}=\frac{\partial w(\mathbf{u}(\mathbf{x},\,t))}{\partial\mathbf{x}}=\frac{\partial w}{\partial\mathbf{u}}\;\frac{\partial \mathbf{u}}{\partial \mathbf{x}}=-\frac{\partial w}{\partial\mathbf{u}}$$
Then
$$\frac{\partial w}{\partial t}=\frac{\partial w(\mathbf{u}(\mathbf{x} ,\, t))}{\partial t}=\frac{\partial w}{\partial\mathbf{u}}\cdot\,\frac{\partial \mathbf{u}}{\partial t}=-\nabla w\cdot\,\mathbf{v}_i=-\nabla\cdot\,(w\,\mathbf{v}_i)+w\,\nabla\cdot\,\mathbf{v}_i=-\nabla\cdot\,(w\,\mathbf{v}_i)$$
Eventually
$$\boxed{\frac{\partial w}{\partial t}=-\nabla\cdot\,(w\,\mathbf{v}_i)}$$
It the next steps it will be clear how this condition resembles and also gives the foundations to continuum mechanics continuity equation.
We may define
$$\qquad\qquad \rho_w(\mathbf{x} , \,t) \equiv\sum_i\,m_i\;w\qquad\qquad\qquad\qquad\qquad\textbf{Mass density}$$
$$\frac{\partial \rho_w}{\partial t}=\frac{\partial}{\partial t}\,\sum_i\,m_i\;w=\sum_i\,m_i\;\frac{\partial w}{\partial t}=-\sum_i\,m_i\;\nabla\cdot\,(w\,\mathbf{v}_i)=-\nabla\cdot\,\bigg(\sum_i\,m_i\,\mathbf{v}_i\;w\bigg)$$
Eventually
$$\boxed{\frac{\partial \rho_w}{\partial t}+\nabla\cdot\,(\rho_w\,\mathbf{v}_w)=0}$$
Having defined
$$\qquad\qquad\mathbf{v}_w(\mathbf{x},\,t)\equiv\frac{1}{\rho_w}\sum_i\,m_i\,\mathbf{v}_i\;w\qquad\qquad\qquad\qquad\textbf{Velocity field}$$